Page 1 of 1

CEF framework and JS communication performance doubts

PostPosted: Thu Dec 01, 2022 5:34 am
by SuR
A recent project used the CEF framework, and the JS code needed to send a lot of instructions to CEF and back some param.
I know, a normal kind of correspondence:
void Renderer::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context)
{
CefRefPtr<CefV8Value> globalObject = context->GetGlobal();
v8Handler = new V8Handler();
//IMPLEMENT_REFCOUNTING(V8Handler);
CefRefPtr<CefV8Value> nativeCall = CefV8Value::CreateFunction("nativeCall", v8Handler);
globalObject->SetValue("nativeCall", nativeCall, V8_PROPERTY_ATTRIBUTE_READONLY);
}
Register the nativeCall global function for JS.
However, I worry that it will get stuck when you request a lot of data at once, hundreds of requests and do json parsing.
Therefore, I also thought of embedding nodejs environment into CEF and making C++ access shared memory plug-in through node-pyq to become a data channel between js and CEF, but I did not know whether this method is feasible and how difficult it is to practice.
Or there are other ways, and hopefully someone can answer that. Thank you very much.

Re: CEF framework and JS communication performance doubts

PostPosted: Thu Dec 08, 2022 1:53 am
by SuR
Now using 20 timers to test, data transmission is not slow, but CPU consumption, is the problem of the timer? Using C++ publish-subscribe model instead?

Re: CEF framework and JS communication performance doubts

PostPosted: Thu Dec 08, 2022 4:30 am
by SuR
Or the mechanism of CEF communicating with JS and publishing and subscribing, as in the message_router case, but I'm not sure
message_router : https://bitbucket.org/chromiumembedded/ ... ge_router/

Re: CEF framework and JS communication performance doubts

PostPosted: Mon Dec 12, 2022 4:53 pm
by magreenblatt
I worry that it will get stuck when you request a lot of data at once, hundreds of requests and do json parsing.

It depends on what you mean by "a lot of data" and where (what process/thread) you're performing the json parsing.

Re: CEF framework and JS communication performance doubts

PostPosted: Sun Dec 18, 2022 8:26 pm
by SuR
Thank you. Is the data processing better in the browser? Is it easy to get stuck processing data in Render? "A lot of data" means that the Execute API of the V8Handler is called more frequently.

Re: CEF framework and JS communication performance doubts

PostPosted: Sun Dec 18, 2022 9:15 pm
by magreenblatt
JS executes on a single thread in the renderer. That could potentially be a bottleneck.