Bug 1905622 - Wait for load of extension panels, before opening them if Wayland is used. r=#thunderbird-reviewers

This is the result of multiple frustrating days spend on trial-and-error. I was able to
reproduce the issue on a Fedora Workstation 40 installation in a Hyper-V VM and this seems
to fix it for me.

I have absolutly no idea as to *why* this is needed, but it is telling that there actually
is a `isWaylandPopup`getter.

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

--HG--
extra : amend_source : d916443e4cdf78384e5e159b237ca4b71d8320a4
This commit is contained in:
John Bieling 2024-09-23 12:04:38 -04:00
Родитель dcaaca5eb6
Коммит 2cfb77b909
3 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -173,6 +173,11 @@ pref("extensions.overlayloader.loglevel", "warn");
pref("extensions.abuseReport.enabled", false);
// Delay opening of action popups until the browser is fully loaded.
// This is needed on Wayland systems, but can be enabled for other
// systems for debug purposes as well. See Bug 1905622.
pref("extensions.openPopupDelayedFullyLoaded.enabled", false);
// Strict compatibility makes add-ons incompatible by default.
#ifndef RELEASE_OR_BETA
pref("extensions.strictCompatibility", false);

Просмотреть файл

@ -44,6 +44,7 @@ export class BasePopup {
this.contentReady = new Promise(resolve => {
this._resolveContentReady = resolve;
});
this.contentReadyAndResized = Promise.withResolvers();
this.window.addEventListener("unload", this);
this.viewNode.addEventListener("popuphiding", this);
@ -160,6 +161,10 @@ export class BasePopup {
case "Extension:BrowserResized":
this._resolveContentReady();
// The final resize is marked as delayed, which is the one we have to wait for.
if (data.detail == "delayed") {
this.contentReadyAndResized.resolve();
}
if (this.ignoreResizes) {
this.dimensions = data;
} else {

Просмотреть файл

@ -493,6 +493,19 @@ export class ToolbarButtonAPI extends ExtensionAPIPersistent {
const popup =
lazy.ViewPopup.for(this.extension, window.top) ||
this.getPopup(window.top, popupURL);
// Bug 1905622: We have to delay opening the panel, until after its browser
// has been loaded, otherwise the content will be blank.
if (
popup.viewNode.isWaylandPopup ||
Services.prefs.getBoolPref(
"extensions.openPopupDelayedFullyLoaded.enabled"
)
) {
await popup.browserLoaded;
await popup.contentReadyAndResized.promise;
}
popup.viewNode.openPopup(button, "bottomleft topleft", 0, 0);
} else if (!options.requirePopupUrl) {
if (!this.lastClickInfo) {