chromiumembedded / java-cef

Java Chromium Embedded Framework (JCEF). A simple framework for embedding Chromium-based browsers in other applications using the Java programming language.
https://bitbucket.org/chromiumembedded/java-cef
Other
655 stars 147 forks source link

Synchronization of CefMessageRouterConfig is broken #376

Open magreenblatt opened 4 years ago

magreenblatt commented 4 years ago

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 commented 4 years ago

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.