Chrome webtools debugger resumes script execution on its own

时间:2016-07-11 21:27:27

标签: javascript google-chrome

I'm seeing strange behavior out of Chrome devtools. I set a breakpoint in my javascript then the breakpoint hits and execution stops.

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.

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. I failed to mention that in the original post.

I recorded a session where I reload a page after having set 3 breakpoints. I did not touch the keyboard or the mouse after reloading the page. You can see Chrome automatically resuming here. (Sorry for the offsite link) In this instance the background of the JS window did not turn yellow for some instance.

Thanks

1 个答案:

答案 0 :(得分:6)

我终于找到了导致调试器进入'自动继续'模式。我的Android应用程序使用Android的WebView loadUrl API在页面上执行一些JS。它使用此调用每5秒调用一次计时器:

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

这显然会导致Chrome恢复执行,以便它可以执行应用程序请求的JS代码。

我很失望,我花了很长时间才追查这件事。

如果在任何时候运行时决定启动你,那么调试JS有点困难的IMO ......

我打算做一些研究,看看我是否能在谷歌上找到任何相关内容。