brightray icon indicating copy to clipboard operation
brightray copied to clipboard

ShowDevTools fired before debugger is ready

Open JavaScriptDude opened this issue 10 years ago • 3 comments

As discussed in my StackOverflow post, the DevTools is shown before the debugger is ready to start executing breakpoints. This makes it difficult to debug breakpoints in the boot code of an electron app. The only workaround is to add an adhoc timeout to wait until the devtools debugger "should" be ready assert breakpoints in client code.

I found a comment in the atom => devtools shim /atom/brightray/blob/master/browser/inspectable_web_contents_impl.cc where in method InspectableWebContentsImpl::ShowDevTools() states the following:

  // Show devtools only after it has done loading, this is to make sure the
  // SetIsDocked is called *BEFORE* ShowDevTools.

The statement "Show devtools only after it has done loading" is not really satisfied IMO as the debugger is not ready to start asserting breakpoints.

Is it possible to look at updating this method so the Dev Tools is tested to see if its ready to start asserting breakpoints before the dev tools is actually shown? Maybe we can add a flag in the package.json that the ShowDevTools method looks for to assert that the debugger is fully ready?

JavaScriptDude avatar Jul 17 '15 23:07 JavaScriptDude

I was reviewing the code and was thinking that it may be more agreeable to all if we were to conditionally spawn a new thread that watches for Dev Tools debugger to be read and once the ready state is detected emit an event back to the user in JavaScript. This way we can turn this on only if specified in package.json and the code will not interrupt the existing execution chain.

JavaScriptDude avatar Jul 19 '15 19:07 JavaScriptDude

Please find a simplified test case for this issue in Electron.

JavaScriptDude avatar Jul 21 '15 03:07 JavaScriptDude

I can confirm this bug, the time devtools-opened is emitted is actually when devtools is loaded completely, but debugger only works after a few time later, which I guess is when devtools has setup connection with the inspected page. Chromium didn't expose an event for this, I think it is because people usually open the devtools and then reload to stop at the breakpoint.

zcbenz avatar Aug 04 '15 08:08 zcbenz