From 30890793e12271684f52f06e1c94fac2146f3063 Mon Sep 17 00:00:00 2001 From: Ryan Doupe Date: Mon, 26 Oct 2026 14:19:23 -0400 Subject: [PATCH] Initialise dock later to bypass startup crash QCefWidgetInternal::showEvent created the browser at once (Init()). While OBS restores a saved dock layout at startup, Qt can show a browser dock and close it again straight away; on Windows, creating the browser in between crashes CEF. This is most often seen with a Twitch Chat dock that was closed before OBS quit. Create the browser on the next event loop pass instead, through a zero-delay single-shot timer with the widget as its context: Qt drops the call if the widget is destroyed before it runs. The upstream change captured `this` in a lambda without a context object, which would call Init() on a destroyed widget in that case. The 500 ms retry timer is unchanged. Ported from upstream obs-browser PR 554 (open upstream at the time of porting). Refs obs-rust/obs-studio#2524 Co-Authored-By: Matt Gajownik --- panel/browser-panel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/panel/browser-panel.cpp b/panel/browser-panel.cpp index e6751de..36ecf2a 100644 --- a/panel/browser-panel.cpp +++ b/panel/browser-panel.cpp @@ -438,7 +438,11 @@ void QCefWidgetInternal::showEvent(QShowEvent *event) obs_browser_initialize(); connect(&timer, &QTimer::timeout, this, &QCefWidgetInternal::Init); timer.start(500); - Init(); + /* Not from inside showEvent: restoring a saved dock layout can + * show a dock and close it again at once, and creating the + * browser in between crashes CEF. With this widget as context, + * the call is dropped if the widget is destroyed first. */ + QTimer::singleShot(0, this, &QCefWidgetInternal::Init); } }