tor-browser

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

commit 21ba2b46059a651265ddd1904b1dce0be02e04f7
parent f81fae7890605739dd8dde14755f159fe6beb8aa
Author: Brad Werth <werth@efn.org>
Date:   Wed, 26 Nov 2025 15:24:58 +0000

Bug 1972888 Part 1: Remove nsCocoaWindow::mClosedRetainedWindow. r=mac-reviewers,mstange

The macOS window manager seems to hold onto the native window until it
is released, even after it is closed. Leaving it retained creates side
effects with window cycling, and with "ghost windows" which might
capture mouse events or be displayed in Mission Control.

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

Diffstat:
Mwidget/cocoa/nsCocoaWindow.h | 1-
Mwidget/cocoa/nsCocoaWindow.mm | 10+---------
2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h @@ -524,7 +524,6 @@ class nsCocoaWindow final : public nsIWidget { nsresult DoMakeFullScreen(bool aFullScreen, bool aUseSystemTransition); BaseWindow* mWindow; // our cocoa window [STRONG] - BaseWindow* mClosedRetainedWindow; // a second strong reference to our // window upon closing it, held through our destructor. This is useful // to ensure that macOS run loops which reference the window will still // have something to point to even if they don't use proper retain and diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm @@ -4624,7 +4624,6 @@ BOOL ChildViewMouseTracker::WindowAcceptsEvent(NSWindow* aWindow, nsCocoaWindow::nsCocoaWindow() : mWindow(nil), - mClosedRetainedWindow(nil), mDelegate(nil), mChildView(nil), mBackingScaleFactor(0.0), @@ -4673,12 +4672,7 @@ void nsCocoaWindow::DestroyNativeWindow() { // sent to it after this object has been destroyed. mWindow.delegate = nil; - // Closing the window will also release it. Our second reference will - // keep it alive through our destructor. Release any reference we might - // have from an earlier call to DestroyNativeWindow, then create a new - // one. - [mClosedRetainedWindow autorelease]; - mClosedRetainedWindow = [mWindow retain]; + // Closing the window will also release it. MOZ_ASSERT(mWindow.releasedWhenClosed); [mWindow close]; @@ -4697,8 +4691,6 @@ nsCocoaWindow::~nsCocoaWindow() { DestroyNativeWindow(); } - [mClosedRetainedWindow release]; - // Our NativeLayerRoot must be empty before it is destructed. if (mNativeLayerRoot) { mNativeLayerRoot->SetLayers({});