v8 protocol not progressing after id:8

299 views
Skip to first unread message

Harsha HS

unread,
May 8, 2017, 10:31:43 AM5/8/17
to v8-users
Hi,
I am trying to use chrome protocol with chrom-devtools in front end.
I am not receiving any message from frontend after id:8

 message {"id":1,"method":"Runtime.enable"}
 message {"id":2,"method":"Debugger.enable"}
 message {"id":3,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}}
 message {"id":4,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":0}}
 message {"id":5,"method":"Profiler.enable"}
 message {"id":6,"method":"Profiler.setSamplingInterval","params":{"interval":100}}
 message {"id":7,"method":"Debugger.setBlackboxPatterns","params":{"patterns":[]}}
message {"id":8,"method":"Runtime.runIfWaitingForDebugger"}

For each of these messages, I am replying to frontend with {id:xx, result:{}}.


-Harsha

Anoop R. S.

unread,
May 18, 2017, 4:05:15 AM5/18/17
to v8-users

Hi Harsha,
We also developed a debugging framework for JS using V8 inspector. While doing that, in between we were also getting this error, but resolved it by debugging our code. 
I can send you the websocket messages that we are getting. Maybe that would help in some way.
I haven't run your code provided at [https://github.com/hsharsha/v8inspector]. Maybe if you need further help, I can check it.


{"id":1,"method":"Log.enable"}

{"id":2,"method":"Log.startViolationsReport","params":{"config":[{"name":"longTask","threshold":200},{"name":"longLayout","threshold":30},{"name":"blockedEvent","threshold":100},{"name":"blockedParser","threshold":-1},{"name":"handler","threshold":150},{"name":"recurringHandler","threshold":50}]}}

{"id":3,"method":"Network.enable","params":{"maxTotalBufferSize":10000000,"maxResourceBufferSize":5000000}}

{"id":4,"method":"Page.enable"}

{"id":5,"method":"Page.getResourceTree"}

{"id":6,"method":"Runtime.enable"}

{"id":7,"method":"Debugger.enable"}

{"id":8,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}}

{"id":9,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":0}}

{"id":10,"method":"DOM.enable"}

{"id":11,"method":"CSS.enable"}

{"id":12,"method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":true}}

{"id":13,"method":"Profiler.enable"}

{"id":14,"method":"Profiler.setSamplingInterval","params":{"interval":100}}

{"id":15,"method":"ServiceWorker.enable"}

{"error":{"code":-32601,"message":"'Log.enable' wasn't found"},"id":1}

{"error":{"code":-32601,"message":"'Log.startViolationsReport' wasn't found"},"id":2}

{"error":{"code":-32601,"message":"'Network.enable' wasn't found"},"id":3}

{"error":{"code":-32601,"message":"'Page.enable' wasn't found"},"id":4}

{"error":{"code":-32601,"message":"'Page.getResourceTree' wasn't found"},"id":5}

{"method":"Runtime.executionContextCreated","params":{"context":{"id":1,"origin":"","name":""}}}

{"id":6,"result":{}}

{"method":"Debugger.scriptParsed","params":{"scriptId":"22","url":"my_Screen1","startLine":0,"startColumn":0,"endLine":19,"endColumn":0,"executionContextId":1,"hash":"FF07566204EF7A37E97781F777DD9282456E48B3","isLiveEdit":false,"sourceMapURL":"","hasSourceURL":false}}

{"id":22,"method":"Debugger.setBreakpointByUrl","params":{"lineNumber":13,"url":"my_Screen1","columnNumber":39,"condition":""}}

{"id":7,"result":{}}

{"id":8,"result":{}}

{"id":9,"result":{}}

{"error":{"code":-32601,"message":"'DOM.enable' wasn't found"},"id":10}

{"error":{"code":-32601,"message":"'CSS.enable' wasn't found"},"id":11}

{"error":{"code":-32601,"message":"'Target.setAutoAttach' wasn't found"},"id":12}

{"id":13,"result":{}}

{"id":14,"result":{}}

{"error":{"code":-32601,"message":"'ServiceWorker.enable' wasn't found"},"id":15}

{"id":16,"result":{}}

{"error":{"code":-32601,"message":"'Page.setAutoAttachToCreatedPages' wasn't found"},"id":17}

{"error":{"code":-32601,"message":"'Emulation.setScriptExecutionDisabled' wasn't found"},"id":18}

{"error":{"code":-32601,"message":"'Rendering.setShowViewportSizeOnResize' wasn't found"},"id":19}

{"error":{"code":-32601,"message":"'Inspector.enable' wasn't found"},"id":20}

{"id":21,"result":{}}

{"id":22,"result":{"breakpointId":"my_Screen1:13:39","locations":[{"scriptId":"22","lineNumber":13,"columnNumber":39}]}}


Please let me know if this is of any help for you.

regards,
Anoop R. S.

Anoop R. S.

unread,
May 29, 2017, 1:12:33 AM5/29/17
to v8-users
Hi Harsha,
Is it setting the breakpoints by passing "method":"Debugger.setBreakpointByUrl" ? 
Seems like it is having problems on pausing: pausing at a breakpoint, pausing after singlestep operation. 
runMessageLoopOnPause function is called when debugger pauses (at a breakpoint, after step over etc) 


Here is my call stack when pause happens after a step over. You can use it for debugging.

> ChromeDbgServer.exe!V8SFWInspector::runMessageLoopOnPause(int contextGroupId)  Line 18 C++
  v8.dll!v8_inspector::V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::Array> hitBreakpointNumbers, bool isPromiseRejection, bool isUncaught)  Line 519 C++
  v8.dll!v8_inspector::V8Debugger::handleV8DebugEvent(const v8::DebugInterface::EventDetails & eventDetails)  Line 620 C++
  v8.dll!v8_inspector::V8Debugger::v8DebugEventCallback(const v8::DebugInterface::EventDetails & eventDetails)  Line 540 C++
  v8.dll!v8::internal::Debug::CallEventCallback(v8::DebugEvent event, v8::internal::Handle<v8::internal::Object> exec_state, v8::internal::Handle<v8::internal::Object> event_data, v8::Debug::ClientData * client_data)  Line 1903 C++
  v8.dll!v8::internal::Debug::ProcessDebugEvent(v8::DebugEvent event, v8::internal::Handle<v8::internal::JSObject> event_data, bool auto_continue)  Line 1880 C++
  v8.dll!v8::internal::Debug::OnDebugBreak(v8::internal::Handle<v8::internal::Object> break_points_hit, bool auto_continue)  Line 1818 C++
  v8.dll!v8::internal::Debug::Break(v8::internal::JavaScriptFrame * frame)  Line 573 C++
  v8.dll!v8::internal::__RT_impl_Runtime_DebugBreak(v8::internal::Arguments args, v8::internal::Isolate * isolate)  Line 35 C++
  v8.dll!v8::internal::Runtime_DebugBreak(int args_length, v8::internal::Object * * args_object, v8::internal::Isolate * isolate)  Line 25 + 0xde bytes C++

Hope I am not too late for the reply.

regards,
Anoop R. S.

--From Mail

Hi Anoop,

 Thanks for your reply and very sorry for the delay in my reply as I was on vacation and did not get a chance to work on the inspector code.

I fixed issue which was a silly mistake from my end as I was allocating the agent variable on stack which go cleaned up once the function returned.

Now I could establish connection with the chrome-dev tools client and communicate with the debug server.
I am facing an issue here.
i) It is not breaking on the first statement, even though I have wait implemented
ii) I can now stop the execution using halt from the chrome-dev tools. But If I do single-step or step out, the execution just continues (work as continue instead of single step) and again I have to press halt on chrome-dev tools to break the execution.

If you can take a look at github.com/hsharsha/v8inspector, would appreciate greatly.

Thanks,
-Harsha

Harsha HS

unread,
Jun 6, 2017, 1:27:24 PM6/6/17
to v8-users
Hi,

runMessageLoopOnPause and quitMessageLoopOnPause seems to be working correctly. When the debugger is paused using the halt icon on chrome-dev tools, runMessageLoopOnPause is called and it is just pumping messages to platform and when continued quitMessageLoopOnPause is called and the java script execution continues.

I am facing issue with single step, break, step into or step over functionality. Debugger is not paused when these methods are hit.
It looks like a synchronization issue between inspector thread and java script execution thread.
How to synchronize between JS execution and inspector protocol?

Thanks,
-Harsha

Zac Hansen

unread,
Jun 7, 2017, 1:39:57 AM6/7/17
to v8-users
Are you having trouble setting those or when those are hit?   

When they are hit, your code will go into the same callback as when you manually pause, from what I've seen.  Are you processing messages while in the pause callback?  

Harsha HS

unread,
Jun 7, 2017, 1:46:29 AM6/7/17
to v8-users
Having trouble when those are hit. I am able to set breakpoints
I am processing messages in the pause loop. I can watch and respond to getProperty methods when paused.
But only way to pause in my code is by hitting halt on the dev-tools.
Any other action like step, will just continue the JS execution and it wont hit breakpoints. Only way to pause again is to hit halt.
It depends on libuv to interact with browser.

Thanks,
-Harsha

Zac Hansen

unread,
Jun 7, 2017, 2:08:52 AM6/7/17
to v8-users
I searched your code for runMessageLoopOnPause and didn't find an override in your subclass.   I'm no expert, but the code that I have that works is:




virtual void runMessageLoopOnPause(int contextGroupId) override {
this->paused = true;
while (this->paused) {
this->channel->run_one();
}
std::cerr << fmt::format("exiting runMessageLoopOnPause") << std::endl;
} Where run_one is what gives my websocket server a chance to deal with incoming chrome debug protocol messages.

Zac Hansen

unread,
Jun 7, 2017, 2:11:20 AM6/7/17
to v8-users

Zac Hansen

unread,
Jun 7, 2017, 3:51:11 AM6/7/17
to v8-users
I'm not sure what the PumpMessageLoop call does, but have you tried it without?

That sounds like it might start execution of code even though it is supposed to be paused.   

Harsha HS

unread,
Jun 7, 2017, 4:06:45 AM6/7/17
to v8-users
It does not work if I do not call PumpMessageLoop in the pause loop. This is needed to push message from frontend to the backend.
If I comment this out, inspector will pause when hit on halt but does not respond to any other front end messages.

Zac Hansen

unread,
Jun 7, 2017, 4:09:45 AM6/7/17
to v8-users
That's odd.  I don't have any such call and everything works fine for me -- in the code I linked to above.

Though I'm not exactly sure what you mean by "frontend" and "backend" in this case.   When javascript is paused, it's not supposed to be doing anything except processing messages from the debugger, as far as I know.

Zac Hansen

unread,
Jun 7, 2017, 5:53:32 PM6/7/17
to v8-users
Sorry if I'm bothering you or not helping, but...

Where are you calling your dispatchMessageFromFrontend from?   Maybe I'm searching poorly again, but I dont' see a call.   Sending the message received from your websocket to that call is what, by my limited understanding, is what takes care of processing the messages from the debugger (is that what you're calling the frontend?).   



In my code, when I receive a message from the websocket, I call that function with the raw contents from the websocket frame:


And then I don't to any PumpMessage functions during my pause loop.  When I'm in the pause function, I just poll my websocket, which calls that code above when a frame is received, and all my debugging calls just magically work.  

Let me know if you want me to stop trying to help.

Harsha HS

unread,
Jun 7, 2017, 10:55:51 PM6/7/17
to v8-users
Hi,

 I am calling dispatchMessageFromFrontend at
in DispatchMessages function.
Frontend is the message I receive from websocket.

I am having an incoming_meesage_queue which queues the messages received from websocket and calls dispatchProtocolmessage by dequeueing these messages one after he other.
I collect the result from the backend/v8_inspector and put them in outgoing_message_queue and this is transmitted on websocket whenever sendProtocolNotificaiton or sendProtocolMessage function is called.

I am using libuv for asyncIO and I think you are using boost for the same.

I truly appreciate your help. 

Zac Hansen

unread,
Jun 7, 2017, 11:31:13 PM6/7/17
to v8-users
Your understanding of this is either wrong or correct and way beyond my comprehension -- and I have no way of knowing which. 

Your function says:

 // This function can be reentered if there was an incoming message while
  // V8 was processing another inspector request (e.g. if the user is
  // evaluating a long-running JS code snippet). This can happen only at
  // specific points (e.g. the lines that call inspector_ methods)

But how would you have the ability to run additional javascript code while javascript code (the long-running JS code snippet) is still running.   Are you debugging across multiple isolates simultaneously?   



My code that works is very simple.   It just sits in the pause loop until it gets a websocket message, processes that one message while not attempting to do anything else, then goes back into the pause loop.   where it then looks for another message.   For debugging a single isolate, I don't see any benefit to handling messages in a more complex order.   I just let the websocket/socket library deal with queueing the messages as I never expect to get more in a fast sequence than I can handle in that manner.  

I'm really interested to know if the complexity of your code is to support a more advanced use case or if it's needless complexity potentially leading to your problem.   

Zac Hansen

unread,
Jun 16, 2017, 5:41:58 PM6/16/17
to v8-users
did you ever figure this out?  I'm working with very similar parts of v8 right now and am quite interested in what you may have learned.

Thanks.

--Zac

Harsha HS

unread,
Jun 17, 2017, 1:32:45 PM6/17/17
to v8-u...@googlegroups.com
Hi,

 Looks like v8-inspector APIs have changed between v8 verison 5.5 and v8 version 5.9. I am trying to port my changes to 5.9 similar to what node has done in their master or 8.x branch

-Harsha

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to a topic in the Google Groups "v8-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-users/s_8D-VavUg4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to v8-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zac Hansen

unread,
Jun 17, 2017, 9:31:11 PM6/17/17
to v8-u...@googlegroups.com
Oh.  I didn't realize you were still on the old Api.  

To unsubscribe from this group and all its topics, send an email to v8-users+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to a topic in the Google Groups "v8-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-users/s_8D-VavUg4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to v8-users+u...@googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages