Bug 1663209 - Use Services.tm.dispatchToMainThread instead of setTimeout when opening a new window. r=mkmelin a=wsmwk
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 21 Sep 2020 15:41:53 +1200
changeset 39869 4a6f993eb5be5609cbc58cbf3b511cff50f6828e
parent 39868 488aa435a29bfb777d09d53fa25bb238af653262
child 39870 b37594670eeed2cbacc97469642d6c605c53c930
push id2768
push userthunderbird@calypsoblue.org
push dateThu, 24 Sep 2020 22:43:00 +0000
treeherdercomm-beta@50f1b08436b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, wsmwk
bugs1663209
Bug 1663209 - Use Services.tm.dispatchToMainThread instead of setTimeout when opening a new window. r=mkmelin a=wsmwk This appears to clear up the test mail/test/browser/tabmail/browser_dragndrop.js, but I'm not sure why the setTimeout call never fires. Differential Revision: https://phabricator.services.mozilla.com/D90818
mail/base/content/msgMail3PaneWindow.js
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -909,19 +909,19 @@ function LoadPostAccountWizard() {
 
   // XXX Do not select the folder until the window displays or the threadpane
   //  will be at minimum size.  We used to have
   //  gFolderDisplay.ensureRowIsVisible use settimeout itself to defer that
   //  calculation, but that was ugly.  Also, in theory we will open the window
   //  faster if we let the event loop start doing things sooner.
 
   if (startMsgHdr) {
-    window.setTimeout(loadStartMsgHdr, 0, startMsgHdr);
+    Services.tm.dispatchToMainThread(() => loadStartMsgHdr(startMsgHdr));
   } else {
-    window.setTimeout(loadStartFolder, 0, startFolderURI);
+    Services.tm.dispatchToMainThread(() => loadStartFolder(startFolderURI));
   }
 
   setTimeout(reportAccountTypes, 0);
   setTimeout(reportAddressBookTypes, 0);
 }
 
 /**
  * Report account types to telemetry. For im accounts, use `im_protocol` as
@@ -1065,17 +1065,17 @@ async function atStartupRestoreTabs(aDon
   let state = await SessionStoreManager.loadingWindow(window);
   if (state) {
     let tabsState = state.tabs;
     let tabmail = document.getElementById("tabmail");
     tabmail.restoreTabs(tabsState, aDontRestoreFirstTab);
   }
 
   // it's now safe to load extra Tabs.
-  setTimeout(loadExtraTabs, 0);
+  Services.tm.dispatchToMainThread(loadExtraTabs);
   SessionStoreManager._restored = true;
   Services.obs.notifyObservers(window, "mail-tabs-session-restored");
   return !!state;
 }
 
 /**
  * Loads and restores tabs upon opening a window by evaluating window.arguments[1].
  *