Skip to content

macOS: no hang on quit when the first browser source is created off the main thread during shutdown #2391

Closed

Description

@vpacher

Summary

Follow-up from the coordinator review of obs-rust/obs-browser#10 (#2387, obs-rust/obs-browser#10 (review)). On macOS, obs_browser_initialize() now hands BrowserInit() to the Qt main thread with a blocking queued call when it is called from another thread. If that happens while OBS shuts down, after Qt's main loop has stopped, nothing runs the queued call, and the calling thread waits forever: OBS hangs on quit.

It needs a first browser source created off the main thread during shutdown (for example an obs-websocket CreateInput that arrives while OBS quits), so it is rare, but a hang on quit is hard to diagnose.

Scope

  • obs-rust/obs-browser obs_browser_initialize() (Qt-loop build): when the Qt application is closing down (QCoreApplication::closingDown()), do not hand BrowserInit() to the main thread; leave CEF uninitialized, as for a failed initialization.
  • Keep the hand-over in a small helper without CEF (for example RunOnQtMainThread(std::function<void()>), returning whether it ran), so it can be tested on its own.

Acceptance criteria

  • RED then GREEN in obs-browser: a Qt Core test calls the helper from a worker thread after the application's event loop has finished, and requires it to return within a timeout without running the function. The same test shows that it still runs the function on the main thread while the loop runs.
  • tests/first_source_off_main_thread.py still passes on macOS.

Suggested: P3, size:S.

Activity

  1. vpacher commented on Oct 25, 2026

    @vpacher
    MemberAuthor

    Claiming: investigation

    Plan, as in the description:

    1. RED in obs-rust/obs-browser: the hand-over to the Qt main thread moves into a helper without CEF, and a Qt Core test calls it from a worker thread after the event loop has finished (it must return within a timeout without running the function) and while the loop runs (it must run the function on the main thread).
    2. GREEN: the helper does not hand over when QCoreApplication::closingDown(), and obs_browser_initialize() leaves CEF uninitialized then.
    3. tests/first_source_off_main_thread.py on macOS, then the submodule bump here.
  2. moved this from Investigating to Done in obs-rust Multiviewon Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs-investigationUnderdefined: research before it can be Ready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions