tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit add312760cc6101eba159772b6caedf4893f297b
parent 217d8de8c438bad56202570a7d5ef615544c611f
Author: stransky <stransky@redhat.com>
Date:   Thu,  6 Nov 2025 14:34:16 +0000

Bug 1998382 [Wayland] Make wl_surface persistent and don't delete it on unmap r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D271379

Diffstat:
Mwidget/gtk/WaylandSurface.cpp | 30+++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/widget/gtk/WaylandSurface.cpp b/widget/gtk/WaylandSurface.cpp @@ -87,10 +87,17 @@ WaylandSurface::WaylandSurface(RefPtr<WaylandSurface> aParent, LOGWAYLAND("WaylandSurface::WaylandSurface(), parent [%p] size [%d x %d]", mParent ? mParent->GetLoggingWidget() : nullptr, mSizeScaled.width, mSizeScaled.height); + struct wl_compositor* compositor = WaylandDisplayGet()->GetCompositor(); + mSurface = wl_compositor_create_surface(compositor); + if (!mSurface) { + LOGWAYLAND(" Failed - can't create surface!"); + } } WaylandSurface::~WaylandSurface() { LOGWAYLAND("WaylandSurface::~WaylandSurface()"); + MozClearPointer(mSurface, wl_surface_destroy); + MOZ_RELEASE_ASSERT(!mIsMapped, "We can't release mapped WaylandSurface!"); MOZ_RELEASE_ASSERT(!mSurfaceLock, "We can't release locked WaylandSurface!"); MOZ_RELEASE_ASSERT(mBufferTransactions.Length() == 0, @@ -486,7 +493,8 @@ bool WaylandSurface::MapLocked(const WaylandSurfaceLock& aProofOfLock, MOZ_DIAGNOSTIC_ASSERT(!mIsMapped, "Already mapped?"); MOZ_DIAGNOSTIC_ASSERT(!(aParentWLSurface && aParentWaylandSurfaceLock), "Only one parent can be used."); - MOZ_DIAGNOSTIC_ASSERT(!mSurface && !mSubsurface, "Already mapped?"); + MOZ_DIAGNOSTIC_ASSERT(!mSubsurface, "Already mapped?"); + MOZ_DIAGNOSTIC_ASSERT(mSurface, "mSurface is missing!"); if (aParentWLSurface) { LOGWAYLAND(" parent wl_surface [%p]", aParentWLSurface); @@ -505,17 +513,9 @@ bool WaylandSurface::MapLocked(const WaylandSurfaceLock& aProofOfLock, mBufferAttached = false; mLatestAttachedBuffer = 0; - struct wl_compositor* compositor = WaylandDisplayGet()->GetCompositor(); - mSurface = wl_compositor_create_surface(compositor); - if (!mSurface) { - LOGWAYLAND(" Failed - can't create surface!"); - return false; - } - mSubsurface = wl_subcompositor_get_subsurface( WaylandDisplayGet()->GetSubcompositor(), mSurface, mParentSurface); if (!mSubsurface) { - MozClearPointer(mSurface, wl_surface_destroy); LOGWAYLAND(" Failed - can't create sub-surface!"); return false; } @@ -600,9 +600,6 @@ void WaylandSurface::GdkCleanUpLocked(const WaylandSurfaceLock& aProofOfLock) { MozClearHandleID(mEmulatedFrameCallbackTimerID, g_source_remove); mIsPendingGdkCleanup = false; - if (!mIsMapped) { - MozClearPointer(mSurface, wl_surface_destroy); - } } void WaylandSurface::ReleaseAllWaylandTransactionsLocked( @@ -648,12 +645,6 @@ void WaylandSurface::UnmapLocked(WaylandSurfaceLock& aSurfaceLock) { MozClearPointer(mPendingOpaqueRegion, wl_region_destroy); MozClearPointer(mOpaqueRegionFrameCallback, wl_callback_destroy); - // We can't release mSurface if it's used by Gdk for frame callback routing, - // it will be released at GdkCleanUpLocked(). - if (!mIsPendingGdkCleanup) { - MozClearPointer(mSurface, wl_surface_destroy); - } - mIsReadyToDraw = false; mBufferAttached = false; @@ -1053,7 +1044,8 @@ wl_egl_window* WaylandSurface::GetEGLWindow(DesktopIntSize aSize) { LOGWAYLAND("WaylandSurface::GetEGLWindow() eglwindow %p", (void*)mEGLWindow); WaylandSurfaceLock lock(this); - if (!mSurface || !mIsReadyToDraw) { + MOZ_DIAGNOSTIC_ASSERT(mSurface, "Missing wl_surface!"); + if (!mIsReadyToDraw) { LOGWAYLAND(" quit, mSurface %p mIsReadyToDraw %d", mSurface, (bool)mIsReadyToDraw); return nullptr;