Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome webtools debugger resumes script execution on its own

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

like image 819
JJF Avatar asked Jul 11 '16 21:07

JJF


People also ask

How do I stop script execution in Chrome?

Open Chrome DevTools. Press Control+Shift+P or Command+Shift+P (Mac) to open the Command Menu. Start typing javascript , select Disable JavaScript, and then press Enter to run the command. JavaScript is now disabled.

How do I turn off auto debug in Chrome?

Go to the "Sources" tab. At the top right hand side, toggle the button that looks like the pause symbol surrounded by a hexagon (button on the far right) until the color of the circle turns black to turn it off. If the pause symbol isn't blue it may be that you've accidentally marked a line for debugging inspection.

Can you step back in Chrome debugger?

Chrome sources debugging has buttons for step over, step into, and step out. There is no stepping backwards in time to see what were the previous functions.


1 Answers

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. It was on a timer calling into the JS every 5 seconds using this call:

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.

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...

I'm going to do some research and see if I can find anything about this on the Googles.

like image 165
JJF Avatar answered Sep 22 '22 02:09

JJF