Skip to content

Windowed (non-OSR) browser close never fires onBeforeClose -- hangs indefinitely #3

Description

@Thrameos

Summary

TestFrame's default windowed (non-OSR) browser close handshake hangs indefinitely: after the documented 7-step close sequence (windowClosing -> close(false) -> doClose() cancels -> re-dispatch -> close(true) -> doClose() allows -> native window destroyed), CefLifeSpanHandler.onBeforeClose is never invoked, so any test/app blocking on it (e.g. via a CountDownLatch) hangs forever.

Matches upstream chromiumembedded/java-cef#364 ("CefBrowser_N.doClose() unexpectedly closes the host window"), filed by the JCEF/CEF maintainer -- about the same CefBrowser_N.doClose() -> SwingUtilities.invokeLater -> synthetic WINDOW_CLOSING re-dispatch mechanism.

Reproduction

Confirmed reproducible and independent of environment -- identical symptom under two unrelated X setups:

  1. WSLg's real X server (has its own window manager).
  2. A from-scratch Xvfb + icewm + dbus-launch setup (a real, if virtual, X server + WM).

In both cases: onAfterCreated -> resource load -> terminateTest -> close(false) -> doClose() cancels -> close(true) -> doClose() allows -> Frame.dispose() all fire correctly, then nothing. onBeforeClose/cleanupTest never print. jstack on the hung process shows the main thread parked in CountDownLatch.await() at TestFrame.awaitCompletion.

Impact

This blocks running TestFrameTest/DisplayHandlerTest (or any test using TestFrame's default windowed mode) in any headless/CI environment -- they hang forever rather than failing fast. Worked around in #2 by converting those tests to OSR mode instead (OSR's close handshake is purely Java-side and doesn't depend on native window-destroy notification), but the underlying windowed-mode bug remains unfixed.

Environment

  • CEF 146.0.10+g8219561+chromium-146.0.7680.179, linux64
  • WSL2 (Ubuntu), and separately bare Xvfb+icewm

Activity

  1. Thrameos commented on Aug 29, 2026

    @Thrameos
    OwnerAuthor

    Worked around (not fixed) in #2 -- TestFrameTest/DisplayHandlerTest converted to OSR mode to avoid this hang in CI. See plan/findings.md for the full reproduction across two independent environments.

  2. Thrameos commented on Aug 31, 2026

    @Thrameos
    OwnerAuthor

    Re-confirmed today (2026-08-30, separate session) with a fresh dedicated test
    (CefBrowserWrTest, @Disabled, commit fa3afe1): identical symptom --
    WINDOW_CLOSING -> doClose(true) -> doClose(false) all fire correctly,
    then onBeforeClose never arrives. Confirmed it's a true hang, not just
    slow: still stuck after 240s wall-clock (vs. this test's own 30s per-test
    watchdog already having force-failed it). Also re-ruled-out "no window
    manager" as the cause a second, independent way: same result under a fresh
    Xvfb :99 + icewm, matching .azure/scripts/coverage.yml's CI setup
    exactly.

    Flagging one thing this issue's original writeup doesn't mention: since
    TestSetupExtension.close() is a one-time, suite-global teardown hook, this
    isn't just "this one test hangs" -- if a windowed-mode test is ever enabled
    without first fixing this, it blocks the entire suite's shutdown on every
    run, not just its own test.

  3. Thrameos commented on Sep 4, 2026

    @Thrameos
    OwnerAuthor

    Fixed. native/util_linux.cpp's DestroyCefBrowser() now schedules a bounded (2s) fallback via CefPostDelayedTask -- if CEF's own real OnBeforeClose() hasn't arrived by then, JCEF calls the exact same public CefLifeSpanHandler::OnBeforeClose() entry point CEF itself would have called. Root cause: CEF's own X11 self-addressed WM_DELETE_WINDOW ClientMessage (sent via CefWindowX11::Close()) is confirmed sent (via gdb) but never processed, so the real close path never completes on its own for a windowed browser under this environment's X11/AWT window hierarchy.

    CefBrowserWrTest (the first windowed-browser test in the suite) is re-enabled and passing -- verified in isolation. Details: plan/tasks/20260903-03-issue3-windowed-close-onbeforeclose.md.

    🤖 Generated with Claude Code

  4. added 2 commits that reference this issue on Sep 4, 2026
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions