CEF framework and JS communication performance doubts
Posted: Thu Dec 01, 2022 5:34 am
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.
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.