db2e77c
diff --git a/widget/gtk/MozContainerWayland.cpp b/widget/gtk/MozContainerWayland.cpp
db2e77c
--- a/widget/gtk/MozContainerWayland.cpp
db2e77c
+++ b/widget/gtk/MozContainerWayland.cpp
db2e77c
@@ -527,10 +527,16 @@
db2e77c
       return;
db2e77c
     }
db2e77c
 
db2e77c
     LOGWAYLAND("%s [%p] scale %d\n", __FUNCTION__,
db2e77c
                (void*)moz_container_get_nsWindow(container), scale);
db2e77c
+    // There is a chance that the attached wl_buffer has not yet been doubled
db2e77c
+    // on the main thread when scale factor changed to 2. This leads to
db2e77c
+    // crash with the following message:
db2e77c
+    // Buffer size (AxB) must be an integer multiple of the buffer_scale (2)
db2e77c
+    // Removing the possibly wrong wl_buffer to prevent that crash:
db2e77c
+    wl_surface_attach(wl_container->surface, nullptr, 0, 0);
db2e77c
     wl_surface_set_buffer_scale(wl_container->surface, scale);
db2e77c
     wl_container->buffer_scale = scale;
db2e77c
   }
db2e77c
 }
db2e77c
 
db2e77c