Skip to content

StackOverflowException when OSR browser gains Focus #489

Description

@nprice-flextrade

Describe the bug
While running a JCEF-based application, I noticed some unexpected messages being written to the STDERR stream (System.err)

These messages simply read Exception in thread "AWT-EventQueue-0"

After a significant amount of effort, I tracked these down to an unreported StackOverflowError, being triggered by CefClient.onGotFocus

To Reproduce
Steps to reproduce the behavior:

  1. Use the Simple example application
  2. Update useOsr to true in the main method of the MainFrame class
  3. Run the app as normal (ensuring the necessary --add-exports parameters are included for Java 9+)
  4. Observe the System.err log output contains multiple instances of Exception in thread "AWT-EventQueue-0"

Expected behavior
We shouldn't see unexpected errors...

Versions (please complete the following information):

  • OS: Windows
  • Java Version: OpenJDK 17
  • JCEF Version: 99c2f7a
  • CEF Version: 127.3.1

Additional context
Putting a breakpoint in CefClient.onGotFocus reveals that this method is triggered repeatedly, with the following stack:

onGotFocus:461, CefClient (org.cef) [39]
N_SetFocus:-1, CefBrowser_N (org.cef.browser)
setFocus:497, CefBrowser_N (org.cef.browser)
onGotFocus:461, CefClient (org.cef) [38]
...

Activity

Samool1 commented on Apr 28, 2025

@Samool1

Also running into this. Happens when using the same version as in the original issue, but also tried it with:

  • JCEF commit: 1770317
  • CEF version: 132.3.1+g144febe+chromium-132.0.6834.83

While not happening at the exact same time as the exception message, we are having issues with some random crashing on Linux some time after minimizing the LWJGL/GLFW window, which may be related.

We're using a custom CefBrowserOsr implementation that doesn't care about the window implementation itself, only handling rendering through onPaint() calls, but maybe there's something deeper down that watches for focus changes in the process?

We use createBrowser passing 0l as windowHandle, if that matters.

I tried overriding CefBrowser_N.setFocus and making it do nothing, as we don't really care about properly detecting focus in our OSR implementation. That did remove the exception message, but the Linux crashes remain.

KlemenDEV commented on Nov 3, 2025

@KlemenDEV

I can confirm this issue. Is there any updates on this? OSR mode keeps spamming console logs with "exception in thread" on focus changes.

No need for complex setup, basic app with osr causes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug report

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions