File mozilla-bmo1744896.patch of Package firefox91

# HG changeset patch
# Parent  ad0a849d02ecb337162c4cdd90f292caec1c6085

diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -5537,16 +5537,27 @@ nsresult nsWindow::Create(nsIWidget* aPa
       for (size_t i = 0; i < ArrayLength(widgets) && widgets[i]; ++i) {
         // Double buffering is controlled by the window's owning
         // widget. Disable double buffering for painting directly to the
         // X Window.
         gtk_widget_set_double_buffered(widgets[i], FALSE);
       }
     }
 #endif
+#ifdef MOZ_WAYLAND
+  // Initialize the window specific VsyncSource early in order to avoid races
+  // with BrowserParent::UpdateVsyncParentVsyncSource().
+  // Only use for toplevel windows for now, see bug 1619246.
+  if (GdkIsWaylandDisplay() &&
+      StaticPrefs::widget_wayland_vsync_enabled_AtStartup() &&
+      mWindowType == eWindowType_toplevel) {
+    mWaylandVsyncSource = new WaylandVsyncSource();
+    MOZ_RELEASE_ASSERT(mWaylandVsyncSource);
+  }
+#endif
 
     // We create input contexts for all containers, except for
     // toplevel popup windows
     if (mWindowType != eWindowType_popup) {
       mIMContext = new IMContextWrapper(this);
     }
   } else if (!mIMContext) {
     nsWindow* container = GetContainerWindow();
@@ -5869,27 +5880,20 @@ void nsWindow::PauseCompositor() {
         DestroyLayerManager();
       }
     }
   }
 }
 
 void nsWindow::WaylandStartVsync() {
 #ifdef MOZ_WAYLAND
-  // only use for toplevel windows for now - see bug 1619246
-  if (!GdkIsWaylandDisplay() ||
-      !StaticPrefs::widget_wayland_vsync_enabled_AtStartup() ||
-      mWindowType != eWindowType_toplevel) {
+  if (!mWaylandVsyncSource) {
     return;
   }
 
-  if (!mWaylandVsyncSource) {
-    mWaylandVsyncSource = new WaylandVsyncSource();
-  }
-
   WaylandVsyncSource::WaylandDisplay& display =
       static_cast<WaylandVsyncSource::WaylandDisplay&>(
           mWaylandVsyncSource->GetGlobalDisplay());
 
   if (mCompositorWidgetDelegate) {
     if (RefPtr<layers::NativeLayerRoot> nativeLayerRoot =
             mCompositorWidgetDelegate->AsGtkCompositorWidget()
                 ->GetNativeLayerRoot()) {
openSUSE Build Service is sponsored by