fix(desktop): gate the Browser pane's media pause on dom-ready#239
fix(desktop): gate the Browser pane's media pause on dom-ready#239AprilNEA wants to merge 1 commit into
Conversation
Greptile SummaryThis PR prevents the hidden Browser pane from pausing media before its guest is ready. The main changes are:
Confidence Score: 5/5This looks safe to merge. The identity-based state preserves readiness when React reapplies the callback ref to the same element. A replacement webview remains gated until its own No blocking issues were found in the updated readiness flow.
What T-Rex did
Important Files Changed
Reviews (2): Last reviewed commit: "fix(desktop): gate the Browser pane's me..." | Re-trigger Greptile |
executeJavaScript throws synchronously on an unattached guest, so the .catch never ran and the escaping error unmounted the whole renderer.
Measured this rather than reasoning about it — the concern does not reproduce here, because React Compiler (enabled for this renderer via Instrumented the ref callback and the pause effect, then ran a real-Electron probe that forces the production trigger (persisted Browser URL, Browser section not active): So readiness reaches That said, the coupling you pointed at is worth removing — correctness here should not depend on whether the compiler memoizes. Pushed a revision that holds readiness by element identity instead of a boolean plus a reset: const [readyGuest, setReadyGuest] = useState<WebviewTag | null>(null);
const guestReady = webview !== null && readyGuest === webview;A replacement element is then simply not the ready one, so the Also rebased onto current |
Fixes CODE-380. Shipped in v0.6.0 and v0.6.1 — the desktop renderer boots to a blank window with no error surface for anyone who has opened a page in the Browser pane.
Root cause
BrowserWebviewPane's hidden-media pause callsWebviewTag.executeJavaScripton a guest that is not attached yet. That method throws synchronously — it does not return a rejected promise — so the.catch(noop)never sees it, the error escapes the effect, and React tears down the entire tree.Introduced by #224 (
d078fd49, sub-commit fix(desktop): pause Browser pane media when the panel is hidden), not by the resident-webview work that preceded it.Why it hits real users
The crash needs
webview !== null && !visible, and both hold on an ordinary launch:<webview>mounts wheneverrightPanel.browser.url !== null, and that URL is persisted —durableBrowserUrl(store/model.ts:317) drops onlyblob:URLs.visible = rightPanel.open && activeSection === 'browser'is false whenever Browser is not the active section at boot.The ref callback sets the element long before
dom-ready, so the effect fires at mount. Mount-while-hidden is the resident webview's normal path, not an edge case.Fix
Track a
guestReadyflag from adom-readylistener registered alongside the existing nav listeners, and gate the pause effect on it. The flag resets in the ref callback so a replacement element starts not-ready instead of inheriting the previous guest's state. Nothing is swallowed: the.catch(noop)remains only for the genuine post-ready async failure.Verification
A probe forcing the exact production trigger (persisted Browser URL, Browser section not active), same build steps on each side:
#rootchildren<webview>masterThe WebView must be attached to the DOM…pnpm check:ciandpnpm test(222 files / 1732 tests) pass.