Bug 1663209 - Use Services.tm.dispatchToMainThread instead of setTimeout when opening a new window. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 21 Sep 2020 15:41:53 +1200
changeset 30657 7019fe66b32b028d33bb8cb56b87bf3b643bbb2c
parent 30656 c3c5db8aeb74d677a0e3aa638036b32b8bfcf729
child 30658 f81bd27cd9a95ed9eaeab593415d4858619121a1
push id17984
push usergeoff@darktrojan.net
push dateMon, 21 Sep 2020 23:02:43 +0000
treeherdercomm-central@2719fb20cee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1663209
Bug 1663209 - Use Services.tm.dispatchToMainThread instead of setTimeout when opening a new window. r=mkmelin 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].
  *