Skip to content

Skip CEF initialization while another process holds the cache lock - #59

Merged
summeroff merged 1 commit into
streamlabsfrom
fix/skip-cef-init-when-cache-locked
Oct 29, 2026
Merged

summeroff merged 1 commit into
streamlabsfrom
fix/skip-cef-init-when-cache-locked

Conversation

@summeroff

@summeroff summeroff commented Oct 28, 2026 •

Copy link
Copy Markdown

Problem: On Windows with CEF 6613, if a leftover obs64 still holds the profile's process-singleton lock, CefInitialize fails and CEF's teardown hits a use-after-free, crashing obs64 at startup (Sentry ContentMainRunnerImpl::Shutdown, 38 reports / 15 users since 1.22).

Change: Before CefInitialize, check <cache dir>\lockfile (held by Chromium with GENERIC_WRITE + FILE_SHARE_READ + DELETE_ON_CLOSE). Wait up to 3 s for the previous instance to release it; if still held, log an error and take the existing init-failure path. Companion: obs-studio-node now waits for the previous server to exit (separate PR).

Effect: Browser sources are disabled for that session instead of Desktop crashing.

Tests

  • cmake --build build_x64 --config RelWithDebInfo --target obs-browser: builds
  • clang-format 19.1.1 --dry-run -Werror: clean
  • Harness: held lock reported held; released or stale lockfile reported free; check creates no file and doesn't block a later lock
  • Not run: two-instance obs64 test with CEF 6613

With CEF 6613 on Windows, CefInitialize fails when a leftover obs64 still holds the profile's process-singleton lock, and CEF's teardown after the failed init crashes with a use-after-free. Check the lockfile first, wait up to 3s for the previous instance to release it, and otherwise take the existing init-failure path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The harness does not exercise two obs64 instances on Windows with CEF 6613, leaving actual singleton-lock detection and crash-free timeout handling unverified.

No open issues 🎉

What changed in this PR

Adds a Windows-only cache-lock check before CEF initialization to avoid the reported startup crash when another process still holds the browser profile lock.

Changes:

  • Probes the existing Chromium lockfile without creating a file, waiting up to three seconds for release.
  • If the lock remains held or shutdown is requested during the wait, logs an error and takes the initialization-failure path, disabling browser sources for the session.
File Description
obs-browser-plugin.cpp Adds lock detection and bounded polling before CEF initialization on Windows.

Review effort: Balanced

@summeroff
summeroff merged commit 4efe1df into streamlabs Oct 29, 2026
2 checks passed
summeroff added a commit to streamlabs/obs-studio that referenced this pull request Oct 30, 2026
Picks up streamlabs/obs-browser#59: a leftover obs64 holding the CEF profile lock no longer crashes the next launch at startup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants