gh-13414: Fixed browser startup not being responsive (gh-13418)

This commit is contained in:
mr. m
2026-04-26 12:25:44 +02:00
committed by GitHub
parent 2028a9b288
commit 6aafd8cb34
3 changed files with 26 additions and 75 deletions

View File

@@ -689,13 +689,17 @@
--zen-loading-progress-bar-color: color-mix(in srgb, var(--zen-primary-color), light-dark(rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.5)) 70%);
position: fixed;
top: calc(-2px - env(hairline));
/* Minimum -2px, but if its larger, elemenet separation / -2 will be used as top offset, to avoid overlapping with the notification stack */
top: calc(var(--zen-element-separation) / -2);
:root:is([zen-no-padding="true"], [inDOMFullscreen="true"]) & {
top: 4px;
}
:root[zen-single-toolbar="true"] & {
top: calc(var(--zen-element-separation) / -2);
}
left: 50%;
transform: translate(-50%, -50%) scale(0);
background: var(--zen-loading-progress-bar-color);

View File

@@ -76,13 +76,6 @@ class nsZenWorkspaces {
}
async init() {
// Initialize tab selection state
this._tabSelectionState = {
inProgress: false,
lastSelectionTime: 0,
debounceTime: 100, // ms to wait between tab selections
};
// Initialize workspace change mutex
this._workspaceChangeInProgress = false;
@@ -218,42 +211,7 @@ class nsZenWorkspaces {
return true;
}
// Safely select a tab with debouncing to prevent race conditions
async _safelySelectTab(tab) {
if (!tab || tab.closing || !tab.ownerGlobal || tab.ownerGlobal.closed) {
return false;
}
// Check if we need to debounce
const now = Date.now();
const timeSinceLastSelection =
now - this._tabSelectionState.lastSelectionTime;
if (timeSinceLastSelection < this._tabSelectionState.debounceTime) {
await new Promise(resolve =>
setTimeout(
resolve,
this._tabSelectionState.debounceTime - timeSinceLastSelection
)
);
}
// Mark selection as in progress
this._tabSelectionState.inProgress = true;
try {
gBrowser.selectedTab = tab;
this._tabSelectionState.lastSelectionTime = Date.now();
return true;
} catch (e) {
console.error("Error selecting tab:", e);
return false;
} finally {
this._tabSelectionState.inProgress = false;
}
}
async selectEmptyTab(newTabTarget = null) {
selectEmptyTab(newTabTarget = null) {
// Validate browser state first
if (!this._validateBrowserState()) {
console.warn("Browser state invalid for empty tab selection");
@@ -273,12 +231,7 @@ class nsZenWorkspaces {
!this._emptyTab.ownerGlobal.closed &&
gZenVerticalTabsManager._canReplaceNewTab
) {
// Safely switch to the empty tab using our debounced method
const success = await this._safelySelectTab(this._emptyTab);
if (!success) {
throw new Error("Failed to select empty tab");
}
gBrowser.selectedTab = this._emptyTab;
return this._emptyTab;
}
@@ -908,35 +861,29 @@ class nsZenWorkspaces {
tabs[this._tabToSelect] !== this._tabToRemoveForEmpty
) {
this.log(`Found tab to select: ${this._tabToSelect}, ${tabs.length}`);
setTimeout(() => {
let tabToUse = gZenGlanceManager.getTabOrGlanceParent(
tabs[this._tabToSelect + 1] || this._emptyTab
);
gBrowser.selectedTab = tabToUse;
this._removedByStartupPage = true;
gBrowser.removeTab(this._tabToRemoveForEmpty, {
skipSessionStore: true,
});
cleanup();
}, 0);
let tabToUse = gZenGlanceManager.getTabOrGlanceParent(
tabs[this._tabToSelect + 1] || this._emptyTab
);
gBrowser.selectedTab = tabToUse;
this._removedByStartupPage = true;
gBrowser.removeTab(this._tabToRemoveForEmpty, {
skipSessionStore: true,
});
cleanup();
} else {
if (!this._keepSelectedTab) {
this.selectEmptyTab();
shownEmptyTab = true;
}
setTimeout(() => {
this._removedByStartupPage = true;
gBrowser.removeTab(this._tabToRemoveForEmpty, {
skipSessionStore: true,
animate: false,
});
cleanup();
}, 0);
this._removedByStartupPage = true;
gBrowser.removeTab(this._tabToRemoveForEmpty, {
skipSessionStore: true,
animate: false,
});
cleanup();
}
} else {
setTimeout(() => {
cleanup();
}, 0);
cleanup();
}
await selectPromise;
@@ -3287,7 +3234,7 @@ class nsZenWorkspaces {
}
if (!workspaceToSwitch) {
console.error("No workspace found for tab, cannot switch");
await this._safelySelectTab(tab);
gBrowser.selectedTab = tab;
return;
}
@@ -3302,7 +3249,7 @@ class nsZenWorkspaces {
}
// Safely switch to the tab using our debounced method
await this._safelySelectTab(tab);
gBrowser.selectedTab = tab;
} catch (e) {
console.error("Error in switchTabIfNeeded:", e);
}

View File

@@ -20,7 +20,7 @@
"brandShortName": "Zen",
"brandFullName": "Zen Browser",
"release": {
"displayVersion": "1.19.9b",
"displayVersion": "1.19.10b",
"github": {
"repo": "zen-browser/desktop"
},