commit 91b75d161ff7c2a7de6d2cc01cefdbc269e8fd01
parent ee5a7346603bfed48775559e7d301598ed3ccbfd
Author: Markus Stange <mstange.moz@gmail.com>
Date: Wed, 8 Oct 2025 23:06:48 +0000
Bug 1993383 - Trigger a repaint of the window in the parent process after a GPU process crash. r=bradwerth
Differential Revision: https://phabricator.services.mozilla.com/D268052
Diffstat:
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h
@@ -391,13 +391,9 @@ class nsCocoaWindow final : public nsBaseWidget {
bool WidgetPaintsBackground() override { return true; }
void CreateCompositor(int aWidth, int aHeight) override;
- static void FinishCreateCompositor(
- int aWidth, int aHeight,
- mozilla::ipc::Endpoint<mozilla::layers::PNativeLayerRemoteParent>&&
- aParentEndpoint,
- RefPtr<mozilla::layers::NativeLayerRootRemoteMacParent>
- aNativeLayerRootRemoteMacParent);
void DestroyCompositor() override;
+ void NotifyCompositorSessionLost(
+ mozilla::layers::CompositorSession* aSession) override;
void SetCompositorWidgetDelegate(
mozilla::widget::CompositorWidgetDelegate*) override;
diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
@@ -982,6 +982,30 @@ void nsCocoaWindow::DestroyCompositor() {
nsBaseWidget::DestroyCompositor();
}
+void nsCocoaWindow::NotifyCompositorSessionLost(
+ mozilla::layers::CompositorSession* aSession) {
+ // The GPU process has crashed.
+ //
+ // Trigger a repaint of this window.
+ // Without this, WebRender won't receive a display list for this
+ // window until something else triggers a parent-side repaint. So tab
+ // contents would remain frozen until the user moves the mouse over a
+ // UI element, for example.
+ //
+ // The Windows equivalent to this code is InvalidateWindowForDeviceReset.
+ //
+ // We wait for a short time before the repaint in order to avoid
+ // flashing tab content - if we were to trigger the parent-side paint
+ // immediately, the composite would briefly hide the tab contents because
+ // the new compositor won't have a display list for the tab yet.
+ const double kTriggerPaintDelayAfterGpuProcessCrash = 0.4; // 400ms
+ [mChildView performSelector:@selector(markLayerForDisplay)
+ withObject:nil
+ afterDelay:kTriggerPaintDelayAfterGpuProcessCrash];
+
+ nsBaseWidget::NotifyCompositorSessionLost(aSession);
+}
+
void nsCocoaWindow::SetCompositorWidgetDelegate(
mozilla::widget::CompositorWidgetDelegate* aDelegate) {
if (aDelegate) {