简体   繁体   English

Chrome webtools调试器可以自行恢复脚本执行

[英]Chrome webtools debugger resumes script execution on its own

I'm seeing strange behavior out of Chrome devtools. 我看到Chrome devtools的奇怪行为。 I set a breakpoint in my javascript then the breakpoint hits and execution stops. 我在我的javascript中设置了一个断点,然后断点命中并执行停止。

The code window shows the point in my code where the breakpoint is (the window has a yellowish background color to it) and then after 5 seconds execution auto-magically resumes without me telling it to. 代码窗口显示我的代码中断点所在的点(窗口背景颜色为黄色)然后在5秒后执行自动神奇地恢复,而我没有告诉它。

Has anyone else seen this before? 有没有其他人见过这个? It's obviously making it very difficult for me to debug. 这显然让我很难调试。

EDIT: This is Chrome remotely debugging an Android WebView application. 编辑:这是Chrome远程调试Android WebView应用程序。 I failed to mention that in the original post. 我在原帖中没有提到。

I recorded a session where I reload a page after having set 3 breakpoints. 我记录了一个会话,我在设置3个断点后重新加载页面。 I did not touch the keyboard or the mouse after reloading the page. 重新加载页面后,我没有触摸键盘或鼠标。 You can see Chrome automatically resuming here . 您可以在此处看到Chrome自动恢复。 (Sorry for the offsite link) In this instance the background of the JS window did not turn yellow for some instance. (抱歉,非现场链接)在这个例子中,JS窗口的背景在某些情况下没有变黄。

Thanks 谢谢

I finally figured out what was causing the debugger to go into 'auto continue' mode. 我终于找到了导致调试器进入“自动继续”模式的原因。 My Android app was using Android's WebView loadUrl API to execute some JS on the page. 我的Android应用程序使用Android的WebView loadUrl API在页面上执行一些JS。 It was on a timer calling into the JS every 5 seconds using this call: 它使用此调用每5秒调用一次计时器:

webView.loadUrl("javascript:" + callBack + "('" + cbData.toString() + "');");

That apparently causes Chrome to resume execution so that it can execute the JS code the app is requesting. 这显然会导致Chrome恢复执行,以便它可以执行应用程序请求的JS代码。

I'm disappointed that it took so long for me to track this down. 我很失望,我花了这么长时间来追踪这一点。

Makes debugging the JS a little difficult IMO if at any time the runtime decides to startup on you... 如果在任何时候运行时决定启动你,那么调试JS有点困难的IMO ......

I'm going to do some research and see if I can find anything about this on the Googles. 我打算做一些研究,看看我是否能在谷歌上找到任何相关信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM