understanding v8 Inspector client

1,190 views
Skip to first unread message

ibon tolosana

unread,
Dec 19, 2016, 10:32:13 AM12/19/16
to v8-users
Hi,

i have successfully integrated remote debugging through chrome dev tools to an embedded v8 in an android app. 
I can see v8's loaded source code, do profiling, memory dumps, etc., but JS debugging is not working as expected.

Whenever the debugger hits a breakpoint, the session channel sends a `{"method":"Debugger.paused"...` message to dev tools frontend.
After that, InspectorClient has its method `runMessageLoopOnPause` called from V8Debugger, and here is where things don't fully work on my side.

The JS execution gets only stopped if I don't exit `runMessageLoopOnPause` method. Otherwise, I would get some debugger information, like evaluated variables values, but the javascript execution is not stopped.

My project is quite complex, where several different operations are wired to javascript, like touch or timers.
I assume all external js calls should be disabled while running `runMessageLoopOnPause`, maybe until `quitMessageLoopOnPause` is called ?. However, this is just guessing. For a simpler example, where just some javascript is compiled and run, w/o threading or external stuff working, remote debugger works just fine.

Could anyone point me to a place where i could read about what i am supposed to do on these methods ? Any hints on how to handle debugger interaction at this point would be highly appreciated.

Thanks.


Alexey Kozyatinskiy

unread,
Dec 20, 2016, 2:47:32 AM12/20/16
to v8-users
Hi,

When JavaScript execution is paused (e.g. breakpoint is triggered) V8 send to inspector (DevTools backend inside of V8) message with v8::Break type [1]. On this message inspector send via protocol Debugger.paused notification [2] and call V8InspectorClient::runMessageLoopOnPause method [3]. Client should run nested message loop and process following protocol commands from front-end there inside of this function until inspector doesn't call quitMessageLoopOnPause. When quitMessageLoopOnPause is called and after client finishes nested message loop then execution will be returned to inspector code and then JavaScript execution will be resumed.[4]
There is no complex logic inside of V8 related to pausing execution - execution is paused as long as runMessageLoopOnPause is running.

You need to write own logic to pause other operations.


Thanks,
Aleksey.

ibon tolosana

unread,
Dec 20, 2016, 3:30:50 AM12/20/16
to v8-users
Hi Alexey,

thanks for the answer.

I figured out what was happening on my side. Basically a threading issue:
My app's v8 thread got blocked on runMessageLoopOnPause, so now i make a synchronous runMessageLoopOnPause execution. Before, i was exiting runMessageLoopOnPause to make an asynchronous loop for it, which made debugger breakpoints not work (already left runMessageLoopOnPause). I get now correctly notified on quitMessageLoopOnPause after sinking all inspector messages.

Embedded v8 Inspector integration with chrome dev tools is simply sweet. 
Thanks for the hard work !!!

Best,

- i

Harsha HS

unread,
Jan 11, 2017, 9:20:54 AM1/11/17
to v8-users
Hi ibon,

 Do you have any sample code base of integrating chrome-dev inspector with embedded v8?

Thanks,
-Harsha

Anoop R. S.

unread,
Apr 26, 2017, 2:49:48 AM4/26/17
to v8-users
Hi,
 Your reply to this question helped a lot in understanding the working of runMessageLoopOnPause and quitMessageLoopOnPause functions. 
 Thanks for the explanation and keep up your work!!!
 
regards,
 Anoop R. S.
Reply all
Reply to author
Forward
0 new messages