diff -up firefox-74.0.1/widget/gtk/WindowSurfaceWayland.cpp.mozilla-1627469 firefox-74.0.1/widget/gtk/WindowSurfaceWayland.cpp --- firefox-74.0.1/widget/gtk/WindowSurfaceWayland.cpp.mozilla-1627469 2020-04-06 15:07:16.772431937 +0200 +++ firefox-74.0.1/widget/gtk/WindowSurfaceWayland.cpp 2020-04-06 15:09:57.037320477 +0200 @@ -647,13 +647,14 @@ WindowBackBuffer* WindowSurfaceWayland:: LOGWAYLAND( ("WindowSurfaceWayland::NewWaylandBuffer [%p] Requested buffer [%d " "x %d] DMABuf %d\n", - (void*)this, mWidgetRect.width, mWidgetRect.height, aUseDMABufBackend)); + (void*)this, mWLBufferRect.width, mWLBufferRect.height, + aUseDMABufBackend)); mWaylandBuffer = WaylandBufferFindAvailable( - mWidgetRect.width, mWidgetRect.height, aUseDMABufBackend); + mWLBufferRect.width, mWLBufferRect.height, aUseDMABufBackend); if (!mWaylandBuffer) { - mWaylandBuffer = CreateWaylandBuffer(mWidgetRect.width, mWidgetRect.height, - aUseDMABufBackend); + mWaylandBuffer = CreateWaylandBuffer( + mWLBufferRect.width, mWLBufferRect.height, aUseDMABufBackend); } return mWaylandBuffer; @@ -663,7 +664,7 @@ WindowBackBuffer* WindowSurfaceWayland:: LOGWAYLAND( ("WindowSurfaceWayland::GetWaylandBufferRecent [%p] Requested buffer [%d " "x %d]\n", - (void*)this, mWidgetRect.width, mWidgetRect.height)); + (void*)this, mWLBufferRect.width, mWLBufferRect.height)); // There's no buffer created yet, create a new one for partial screen updates. if (!mWaylandBuffer) { @@ -675,9 +676,10 @@ WindowBackBuffer* WindowSurfaceWayland:: return nullptr; } - if (mWaylandBuffer->IsMatchingSize(mWidgetRect.width, mWidgetRect.height)) { - LOGWAYLAND((" Size is ok, use the buffer [%d x %d]\n", mWidgetRect.width, - mWidgetRect.height)); + if (mWaylandBuffer->IsMatchingSize(mWLBufferRect.width, + mWLBufferRect.height)) { + LOGWAYLAND((" Size is ok, use the buffer [%d x %d]\n", + mWLBufferRect.width, mWLBufferRect.height)); return mWaylandBuffer; } @@ -692,7 +694,7 @@ WindowBackBuffer* WindowSurfaceWayland:: LOGWAYLAND( ("WindowSurfaceWayland::GetWaylandBufferWithSwitch [%p] Requested buffer " "[%d x %d]\n", - (void*)this, mWidgetRect.width, mWidgetRect.height)); + (void*)this, mWLBufferRect.width, mWLBufferRect.height)); // There's no buffer created yet or actual buffer is attached, get a new one. // Use DMABuf for fullscreen updates only. @@ -701,20 +703,21 @@ WindowBackBuffer* WindowSurfaceWayland:: } // Reuse existing buffer - LOGWAYLAND((" Reuse buffer with resize [%d x %d]\n", mWidgetRect.width, - mWidgetRect.height)); + LOGWAYLAND((" Reuse buffer with resize [%d x %d]\n", mWLBufferRect.width, + mWLBufferRect.height)); // OOM here, just return null to skip this frame. - if (!mWaylandBuffer->Resize(mWidgetRect.width, mWidgetRect.height)) { + if (!mWaylandBuffer->Resize(mWLBufferRect.width, mWLBufferRect.height)) { return nullptr; } return mWaylandBuffer; } already_AddRefed WindowSurfaceWayland::LockWaylandBuffer() { - // Allocated wayland buffer must match widget size, otherwise wayland - // compositor is confused and may produce various rendering artifacts. - mWidgetRect = mWindow->GetMozContainerSize(); + // Allocated wayland buffer can't be bigger than mozilla widget size. + LayoutDeviceIntRegion region; + region.And(mLockedScreenRect, mWindow->GetMozContainerSize()); + mWLBufferRect = LayoutDeviceIntRect(region.GetBounds()); // mCanSwitchWaylandBuffer set means we're getting buffer for fullscreen // update. We can use DMABuf and we can get a new buffer for drawing. @@ -882,8 +885,8 @@ already_AddRefed Window LayoutDeviceIntRect size = mWindow->GetMozContainerSize(); // We can draw directly only when widget has the same size as wl_buffer - mDrawToWaylandBufferDirectly = (size.width == mLockedScreenRect.width && - size.height == mLockedScreenRect.height); + mDrawToWaylandBufferDirectly = (size.width >= mLockedScreenRect.width && + size.height >= mLockedScreenRect.height); // We can draw directly only when we redraw significant part of the window // to avoid flickering. diff -up firefox-74.0.1/widget/gtk/WindowSurfaceWayland.h.mozilla-1627469 firefox-74.0.1/widget/gtk/WindowSurfaceWayland.h --- firefox-74.0.1/widget/gtk/WindowSurfaceWayland.h.mozilla-1627469 2020-04-06 15:07:16.773431931 +0200 +++ firefox-74.0.1/widget/gtk/WindowSurfaceWayland.h 2020-04-06 15:07:16.775431919 +0200 @@ -264,11 +264,11 @@ class WindowSurfaceWayland : public Wind // mLockedScreenRect is window size when our wayland buffer was allocated. LayoutDeviceIntRect mLockedScreenRect; - // WidgetRect is an actual size of mozcontainer widget. It can be - // different than mLockedScreenRect during resize when mBounds are updated - // immediately but actual GtkWidget size is updated asynchronously - // (see Bug 1489463). - LayoutDeviceIntRect mWidgetRect; + // mWLBufferRect is an intersection of mozcontainer widgetsize and + // mLockedScreenRect size. It can be different than mLockedScreenRect + // during resize when mBounds are updated immediately but actual + // GtkWidget size is updated asynchronously (see Bug 1489463). + LayoutDeviceIntRect mWLBufferRect; nsWaylandDisplay* mWaylandDisplay; // Actual buffer (backed by wl_buffer) where all drawings go into.