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

Fix thread race conditions

Open magreenblatt opened this issue 5 years ago • 8 comments

Original report by me.


There are a number of issues that appear to be race conditions between the Java AWT thread and the CEF UI thread. We should come up with a common strategy to address this (synchronization, moving execution to a particular thread, etc).

magreenblatt avatar Jul 31 '20 19:07 magreenblatt

Issue #349 was marked as a duplicate of this issue.

magreenblatt avatar Jul 31 '20 19:07 magreenblatt

Issue #332 was marked as a duplicate of this issue.

magreenblatt avatar Jul 31 '20 19:07 magreenblatt

Issue #369 was marked as a duplicate of this issue.

magreenblatt avatar Jul 31 '20 19:07 magreenblatt

See also issue #356, issue #357 and issue #380.

magreenblatt avatar Jul 31 '20 19:07 magreenblatt

This issue mostly surfaces as crashes during JCEF initialization, browser reparenting, and JCEF shutdown. For example, from issue #369:

  1. Tests > Reparent
  2. Click Reparent <
  3. Close new window
  4. Crash with “Check failed: !IsCefShutdown(). Object reference incorrectly held at CefShutdown”

The crash from step 4 also occurs occasionally (but not consistently) when shutting down without reparenting the browser first. See this comment where adding a delay makes it less likely.

Issue #356 and issue #380 include PRs to fix related issues on Linux and Mac respectively. Issue #357 is a related issue in JOGL with Mac OSR.

magreenblatt avatar Jul 31 '20 19:07 magreenblatt

Original comment by Andrei Pivkine (Bitbucket: andreiPiv, GitHub: andreiPiv).


Would love to see this fixed on Windows too :grin:

The two issues I cannot solve are intermittent crashes on calling N_Initialize and N_Shutdown. Usually these are only reproduced in automated testing. (I haven’t tried the absolute latest patches though)

magreenblatt avatar Aug 04 '20 14:08 magreenblatt

Original comment by Andrei Pivkine (Bitbucket: andreiPiv, GitHub: andreiPiv).


does https://bitbucket.org/chromiumembedded/cef/issues/2668/multi-threaded-message-loop-crashes-again fix the issue #349? (The initialization)

magreenblatt avatar Aug 12 '21 16:08 magreenblatt

Same problem here, but specifically on Linux. I have a Compose desktop app that uses JCEF for an internal browser. On Linux specifically, when I try to initialize, my app will crash with a segmentation fault seemingly randomly. It happens more often than not but will sometimes work indicating that this is likely a race condition. From debugging I can pretty confidently say it happens in java event dispatch thread

Sage-Kreiter avatar Mar 06 '24 17:03 Sage-Kreiter