From 833caf2f8188c874acfd70eb854caae19972c605 Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Thu, 27 Nov 2025 16:43:51 +0100 Subject: [PATCH] fix: Fixed crash on macos when quiting and glance opening a new window, b=bug #11416 and bug https://github.com/zen-browser/desktop/issues/11409, c=common, compact-mode, glance, tabs, workspaces --- .../urlbar/UrlbarInput-sys-mjs.patch | 8 ++-- src/firefox-patches/147_https3_fix.patch | 19 ++++++++ src/zen/common/sys/ZenActorsManager.sys.mjs | 3 -- src/zen/compact-mode/ZenCompactMode.mjs | 34 ++++++++----- src/zen/glance/actors/ZenGlanceChild.sys.mjs | 48 ++++++++----------- src/zen/tabs/ZenPinnedTabManager.mjs | 2 +- src/zen/workspaces/ZenWorkspaces.mjs | 6 ++- surfer.json | 2 +- 8 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 src/firefox-patches/147_https3_fix.patch diff --git a/src/browser/components/urlbar/UrlbarInput-sys-mjs.patch b/src/browser/components/urlbar/UrlbarInput-sys-mjs.patch index ac3e26172..13c96ab97 100644 --- a/src/browser/components/urlbar/UrlbarInput-sys-mjs.patch +++ b/src/browser/components/urlbar/UrlbarInput-sys-mjs.patch @@ -1,5 +1,5 @@ diff --git a/browser/components/urlbar/UrlbarInput.sys.mjs b/browser/components/urlbar/UrlbarInput.sys.mjs -index 4b7232f3261f8589b734c2238170e6968d7ea0bf..d8c0b404724e9b0dc2b5a2d21420357586fb7f14 100644 +index 4b7232f3261f8589b734c2238170e6968d7ea0bf..6c68a2e93b7287f92ff394789c50d1c10e8a36f2 100644 --- a/browser/components/urlbar/UrlbarInput.sys.mjs +++ b/browser/components/urlbar/UrlbarInput.sys.mjs @@ -84,6 +84,13 @@ ChromeUtils.defineLazyGetter(lazy, "logger", () => @@ -189,11 +189,13 @@ index 4b7232f3261f8589b734c2238170e6968d7ea0bf..d8c0b404724e9b0dc2b5a2d214203575 if ( event.keyCode == KeyEvent.DOM_VK_SHIFT || event.keyCode == KeyEvent.DOM_VK_ALT || -@@ -3248,7 +3335,7 @@ export class UrlbarInput { +@@ -3247,8 +3334,8 @@ export class UrlbarInput { + if (!this.isAddressbar) { return val; } - let trimmedValue = lazy.UrlbarPrefs.get("trimURLs") +- let trimmedValue = lazy.UrlbarPrefs.get("trimURLs") - ? lazy.BrowserUIUtils.trimURL(val) ++ let trimmedValue = lazy.UrlbarPrefs.get("trimURLs") && this._zenTrimURL + ? this._zenTrimURL(val) : val; // Only trim value if the directionality doesn't change to RTL and we're not diff --git a/src/firefox-patches/147_https3_fix.patch b/src/firefox-patches/147_https3_fix.patch new file mode 100644 index 000000000..3cad042c8 --- /dev/null +++ b/src/firefox-patches/147_https3_fix.patch @@ -0,0 +1,19 @@ +diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp +index daf10b9adb4b6a3c376edc5b0d8586e97483626a..415f64dbb2da5ea6da42f1ce29d6dc09cf86f713 100644 +--- a/netwerk/protocol/http/nsHttpTransaction.cpp ++++ b/netwerk/protocol/http/nsHttpTransaction.cpp +@@ -1332,6 +1332,14 @@ void nsHttpTransaction::Close(nsresult reason) { + mDNSRequest = nullptr; + } + ++ // If an HTTP/3 backup timer is active and this transaction ends in error, ++ // treat it as NS_ERROR_NET_RESET so the transaction will retry once. ++ // NOTE: This is a temporary workaround; the proper fix belongs in ++ // the Happy Eyeballs project. ++ if (NS_FAILED(reason) && mHttp3BackupTimerCreated && mHttp3BackupTimer) { ++ reason = NS_ERROR_NET_RESET; ++ } ++ + MaybeCancelFallbackTimer(); + + MOZ_ASSERT(OnSocketThread(), "not on socket thread"); diff --git a/src/zen/common/sys/ZenActorsManager.sys.mjs b/src/zen/common/sys/ZenActorsManager.sys.mjs index f53f80af2..da9930c1b 100644 --- a/src/zen/common/sys/ZenActorsManager.sys.mjs +++ b/src/zen/common/sys/ZenActorsManager.sys.mjs @@ -45,9 +45,6 @@ let JSWINDOWACTORS = { mousedown: { capture: true, }, - mouseup: { - capture: true, - }, keydown: { capture: true, }, diff --git a/src/zen/compact-mode/ZenCompactMode.mjs b/src/zen/compact-mode/ZenCompactMode.mjs index f5f54fe05..72df3790f 100644 --- a/src/zen/compact-mode/ZenCompactMode.mjs +++ b/src/zen/compact-mode/ZenCompactMode.mjs @@ -52,9 +52,13 @@ window.gZenCompactModeManager = { this._canDebugLog = Services.prefs.getBoolPref('zen.view.compact.debug', false); this.addContextMenu(); + this._resolvePreInit(); }, - init() { + async init() { + await this._preInitPromise; + delete this._resolvePreInit; + delete this._preInitPromise; this.addMouseActions(); const tabIsRightObserver = this._updateSidebarIsOnRight.bind(this); @@ -227,6 +231,9 @@ window.gZenCompactModeManager = { const isIllegalState = this.checkIfIllegalState(); const menuitem = document.getElementById('zen-context-menu-compact-mode-toggle'); const menu = document.getElementById('zen-context-menu-compact-mode'); + if (!menu) { + return; + } if (isSingleToolbar) { menu.setAttribute('hidden', 'true'); menu.before(menuitem); @@ -528,9 +535,11 @@ window.gZenCompactModeManager = { }, updateContextMenu() { - document - .getElementById('zen-context-menu-compact-mode-toggle') - .setAttribute('checked', this.preference); + const toggle = document.getElementById('zen-context-menu-compact-mode-toggle'); + if (!toggle) { + return; + } + toggle.setAttribute('checked', this.preference); const hideTabBar = this.canHideSidebar; const hideToolbar = this.canHideToolbar; @@ -855,10 +864,13 @@ window.gZenCompactModeManager = { }, }; -document.addEventListener( - 'MozBeforeInitialXULLayout', - () => { - gZenCompactModeManager.preInit(); - }, - { once: true } -); +(gZenCompactModeManager._preInitPromise = new Promise((resolve) => { + gZenCompactModeManager._resolvePreInit = resolve; +})), + document.addEventListener( + 'MozBeforeInitialXULLayout', + () => { + gZenCompactModeManager.preInit(); + }, + { once: true } + ); diff --git a/src/zen/glance/actors/ZenGlanceChild.sys.mjs b/src/zen/glance/actors/ZenGlanceChild.sys.mjs index 7d39efdc9..8de0fc65f 100644 --- a/src/zen/glance/actors/ZenGlanceChild.sys.mjs +++ b/src/zen/glance/actors/ZenGlanceChild.sys.mjs @@ -3,11 +3,9 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. export class ZenGlanceChild extends JSWindowActorChild { #activationMethod; - #glanceTarget = null; constructor() { super(); - this.mousemoveCallback = this.mousemoveCallback.bind(this); } async handleEvent(event) { @@ -59,16 +57,32 @@ export class ZenGlanceChild extends JSWindowActorChild { }); } - on_mousedown(event) { + /** + * Returns the closest A element from the event target + * and the element to record (originalTarget or target) + */ + #getTargetFromEvent(event) { // get closest A element const target = event.target.closest('A'); const elementToRecord = event.originalTarget || event.target; + return { + target, + elementToRecord, + }; + } + + on_mousedown(event) { + const { target, elementToRecord } = this.#getTargetFromEvent(event); // We record the link data anyway, even if the glance may be invoked // or not. We have some cases where glance would open, for example, // when clicking on a link with a different domain where glance would open. // The problem is that at that stage we don't know the rect or even what // element has been clicked, so we send the data here. this.#sendClickDataToParent(target, elementToRecord); + } + + on_click(event) { + const { target } = this.#getTargetFromEvent(event); if (event.button !== 0 || event.defaultPrevented || this.#ensureOnlyKeyModifiers(event)) { return; } @@ -82,31 +96,9 @@ export class ZenGlanceChild extends JSWindowActorChild { } else if (activationMethod === 'meta' && !event.metaKey) { return; } - this.#glanceTarget = target; - this.contentWindow.addEventListener('mousemove', this.mousemoveCallback, { once: true }); - } - - on_mouseup() { - if (this.#glanceTarget) { - // Don't clear the glance target here, we need it in the click handler - // See issue https://github.com/zen-browser/desktop/issues/11409 - this.#openGlance(this.#glanceTarget); - } - this.contentWindow.removeEventListener('mousemove', this.mousemoveCallback); - } - - on_click(event) { - if (this.#glanceTarget) { - event.preventDefault(); - event.stopPropagation(); - this.#glanceTarget = null; - } - } - - mousemoveCallback() { - if (this.#glanceTarget) { - this.#glanceTarget = null; - } + event.preventDefault(); + event.stopPropagation(); + this.#openGlance(target); } on_keydown(event) { diff --git a/src/zen/tabs/ZenPinnedTabManager.mjs b/src/zen/tabs/ZenPinnedTabManager.mjs index 8598858a4..c922d1166 100644 --- a/src/zen/tabs/ZenPinnedTabManager.mjs +++ b/src/zen/tabs/ZenPinnedTabManager.mjs @@ -164,7 +164,7 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature { if (init) { this._hasFinishedLoading = true; } - }, 10); + }, 100); } async #initializePinsCache() { diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index cb08f58d0..0816696b6 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -51,7 +51,11 @@ class nsZenWorkspaces extends nsZenMultiWindowFeature { if (this.privateWindowOrDisabled) { return; } - await Promise.all([this.promiseDBInitialized, this.promisePinnedInitialized]); + await Promise.all([ + this.promiseDBInitialized, + this.promisePinnedInitialized, + SessionStore.promiseAllWindowsRestored, + ]); } async init() { diff --git a/surfer.json b/surfer.json index 7f1885ec2..fef136899 100644 --- a/surfer.json +++ b/surfer.json @@ -19,7 +19,7 @@ "brandShortName": "Zen", "brandFullName": "Zen Browser", "release": { - "displayVersion": "1.17.10b", + "displayVersion": "1.17.11b", "github": { "repo": "zen-browser/desktop" },