Bug 1532024 - Handle a case that GetRemoteRenderer() returned nullptr r=stransky
authorsotaro <sotaro.ikeda.g@gmail.com>
Wed, 06 Mar 2019 08:17:51 +0000
changeset 520435 acbeb5adfef5580412f74d1fe9cfbc689ee8d44e
parent 520434 c24728a48d075bfb8f8047af6dd6d6ade9c7c58a
child 520436 5bda26248e68d20a06d197584b020e63ed091bf1
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1532024
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532024 - Handle a case that GetRemoteRenderer() returned nullptr r=stransky Differential Revision: https://phabricator.services.mozilla.com/D21831
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -394,16 +394,20 @@ nsWindow::nsWindow() {
   mOldFocusWindow = 0;
 
   mXDisplay = nullptr;
   mXWindow = X11None;
   mXVisual = nullptr;
   mXDepth = 0;
 #endif /* MOZ_X11 */
 
+#ifdef MOZ_WAYLAND
+  mNeedsUpdatingEGLSurface = false;
+#endif
+
   if (!gGlobalsInitialized) {
     gGlobalsInitialized = true;
 
     // It's OK if either of these fail, but it may not be one day.
     initialize_prefs();
 
 #ifdef MOZ_WAYLAND
     // Wayland provides clipboard data to application on focus-in event
@@ -1867,22 +1871,24 @@ static bool ExtractExposeRegion(LayoutDe
   cairo_rectangle_list_destroy(rects);
   return true;
 }
 
 #ifdef MOZ_WAYLAND
 void nsWindow::WaylandEGLSurfaceForceRedraw() {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
-  if (mIsDestroyed) {
+  if (mIsDestroyed || !mNeedsUpdatingEGLSurface) {
     return;
   }
 
-  if (CompositorBridgeChild* remoteRenderer = GetRemoteRenderer()) {
+  if (CompositorBridgeChild *remoteRenderer = GetRemoteRenderer()) {
+    MOZ_ASSERT(mCompositorWidgetDelegate);
     if (mCompositorWidgetDelegate) {
+      mNeedsUpdatingEGLSurface = false;
       mCompositorWidgetDelegate->RequestsUpdatingEGLSurface();
     }
     remoteRenderer->SendForcePresent();
   }
 }
 #endif
 
 gboolean nsWindow::OnExposeEvent(cairo_t *cr) {
@@ -3478,20 +3484,20 @@ nsresult nsWindow::Create(nsIWidget *aPa
       }
 
       // Create a container to hold child windows and child GtkWidgets.
       GtkWidget *container = moz_container_new();
       mContainer = MOZ_CONTAINER(container);
 #ifdef MOZ_WAYLAND
       if (!mIsX11Display && ComputeShouldAccelerate()) {
         RefPtr<nsWindow> self(this);
-        moz_container_set_initial_draw_callback(mContainer,
-            [self]() -> void {
-              self->WaylandEGLSurfaceForceRedraw();
-            });
+        moz_container_set_initial_draw_callback(mContainer, [self]() -> void {
+          self->mNeedsUpdatingEGLSurface = true;
+          self->WaylandEGLSurfaceForceRedraw();
+        });
       }
 #endif
 
       // "csd" style is set when widget is realized so we need to call
       // it explicitly now.
       gtk_widget_realize(mShell);
 
       /* There are several cases here:
@@ -6053,16 +6059,19 @@ nsIWidget::LayerManager *nsWindow::GetLa
 }
 
 void nsWindow::SetCompositorWidgetDelegate(CompositorWidgetDelegate *delegate) {
   if (delegate) {
     mCompositorWidgetDelegate = delegate->AsPlatformSpecificDelegate();
     MOZ_ASSERT(mCompositorWidgetDelegate,
                "nsWindow::SetCompositorWidgetDelegate called with a "
                "non-PlatformCompositorWidgetDelegate");
+#ifdef MOZ_WAYLAND
+    WaylandEGLSurfaceForceRedraw();
+#endif
   } else {
     mCompositorWidgetDelegate = nullptr;
   }
 }
 
 void nsWindow::ClearCachedResources() {
   if (mLayerManager && mLayerManager->GetBackendType() ==
                            mozilla::layers::LayersBackend::LAYERS_BASIC) {
@@ -6538,18 +6547,17 @@ nsWindow::CSDSupportLevel nsWindow::GetS
   }
 
   return sCSDSupportLevel;
 }
 
 // Check for Mutter regression on X.org (Bug 1530252). In that case we
 // don't hide system titlebar by default as we can't draw transparent
 // corners reliably.
-bool nsWindow::TitlebarCanUseShapeMask()
-{
+bool nsWindow::TitlebarCanUseShapeMask() {
   static int canUseShapeMask = -1;
   if (canUseShapeMask != -1) {
     return canUseShapeMask;
   }
   canUseShapeMask = true;
 
   const char *currentDesktop = getenv("XDG_CURRENT_DESKTOP");
   if (!currentDesktop) {
@@ -6569,17 +6577,18 @@ bool nsWindow::HideTitlebarByDefault() {
   static int hideTitlebar = -1;
   if (hideTitlebar != -1) {
     return hideTitlebar;
   }
 
   // When user defined widget.default-hidden-titlebar don't do any
   // heuristics and just follow it.
   if (Preferences::HasUserValue("widget.default-hidden-titlebar")) {
-    hideTitlebar = Preferences::GetBool("widget.default-hidden-titlebar", false);
+    hideTitlebar =
+        Preferences::GetBool("widget.default-hidden-titlebar", false);
     return hideTitlebar;
   }
 
   const char *currentDesktop = getenv("XDG_CURRENT_DESKTOP");
   hideTitlebar =
       (currentDesktop && GetSystemCSDSupportLevel() != CSD_SUPPORT_NONE);
 
   // Disable system titlebar for Gnome only for now. It uses window
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -428,16 +428,19 @@ class nsWindow final : public nsBaseWidg
 #if GTK_CHECK_VERSION(3, 4, 0)
   // whether we handle touch event
   bool mHandleTouchEvent;
 #endif
   // true if this is a drag and drop feedback popup
   bool mIsDragPopup;
   // Can we access X?
   bool mIsX11Display;
+#ifdef MOZ_WAYLAND
+  bool mNeedsUpdatingEGLSurface;
+#endif
 
  private:
   void DestroyChildWindows();
   GtkWidget* GetToplevelWidget();
   nsWindow* GetContainerWindow();
   void SetUrgencyHint(GtkWidget* top_window, bool state);
   void SetDefaultIcon(void);
   void SetWindowDecoration(nsBorderStyle aStyle);