java-cef icon indicating copy to clipboard operation
java-cef copied to clipboard

Synchronization of CefMessageRouterConfig is broken

Open magreenblatt opened this issue 5 years ago • 1 comments

Original report by Nikita Gubarkov (Bitbucket: YaaZ, GitHub: YaaZ).


Please see https://bitbucket.org/chromiumembedded/cef/issues/2978

As CEF now creates render processes in advance, we cannot pass CefMessageRouterConfig parameters to extra_info of OnRenderThreadCreated, as it’s now called too early for us to know what to pass to it. We cannot use extra_info of OnBrowserCreated as well, because it’s called after OnWebKitInitialized where CefMessageRouterRendererSide is created.

Original issue with JS callbacks was posted on CEF forum, there’s also a test and necessary steps for reproducing the problem: https://magpcss.org/ceforum/viewtopic.php?f=17&t=17599

This is a critical issue, which completely breaks usage of JS callbacks and exists since 78.2.7+g9cd8bac+chromium-78.0.3904.70

magreenblatt avatar Jul 05 '20 11:07 magreenblatt

We cannot use extra_info of OnBrowserCreated as well, because it’s called after OnWebKitInitialized where CefMessageRouterRendererSide is created.

So create the CefMessageRouterRendererSide in OnBrowserCreated instead. OnBrowserCreated might be called multiple times if the render process is used by multiple browsers, so you can either keep a map of browser ID to router, or just use the first registration for all browsers.

Alternately, the registration could be handled via the messages in OnProcessMessageReceived exclusively.

magreenblatt avatar Jul 06 '20 21:07 magreenblatt