Bug 1003968 - avoid Exists() calls for search plugin directories in the browser directory provider r=daleharvey,Gijs
☠☠ backed out by 63dc43dba90a ☠ ☠
authorruthra kumar <ruthrab@gmail.com>
Wed, 21 Aug 2019 09:34:49 +0000
changeset 489148 de151ad69bd613efce11317b30c51bdeeb936f30
parent 489147 82634a1a23743a53cc38bee42e550cc01b76e1ca
child 489149 3576d5b9f2db1053ca2f32181ac2a30b98eaeb7d
push id36465
push userdvarga@mozilla.com
push dateWed, 21 Aug 2019 16:47:43 +0000
treeherdermozilla-central@4ab60925635c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaleharvey, Gijs
bugs1003968
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1003968 - avoid Exists() calls for search plugin directories in the browser directory provider r=daleharvey,Gijs This Change removes all call to Exists() in Directory Provider component, which creates the possibility for the componenet to return an empty list. SearchService.jsm is modified to handle this possibility. Differential Revision: https://phabricator.services.mozilla.com/D42772
browser/base/content/test/performance/browser_startup_mainthreadio.js
browser/components/dirprovider/DirectoryProvider.cpp
toolkit/components/search/SearchService.jsm
--- a/browser/base/content/test/performance/browser_startup_mainthreadio.js
+++ b/browser/base/content/test/performance/browser_startup_mainthreadio.js
@@ -550,23 +550,16 @@ const startupPhases = {
     {
       path: "XREAppFeat:webcompat-reporter@mozilla.org.xpi",
       condition: !WIN,
       ignoreIfUnused: true,
       stat: 1,
       close: 1,
     },
     {
-      // bug 1003968
-      path: "XREAppDist:searchplugins",
-      condition: WIN,
-      ignoreIfUnused: true, // with WebRender enabled this may happen during "before becoming idle"
-      stat: 1,
-    },
-    {
       path: "XCurProcD:extensions",
       condition: WIN,
       stat: 1,
     },
   ],
 
   // Things that are expected to be completely out of the startup path
   // and loaded lazily when used for the first time by the user should
@@ -660,23 +653,16 @@ const startupPhases = {
       stat: 2,
     },
     {
       path: "ProfD:",
       condition: WIN,
       ignoreIfUnused: true,
       stat: 3,
     },
-    {
-      // bug 1003968
-      path: "XREAppDist:searchplugins",
-      condition: WIN,
-      ignoreIfUnused: true, // with WebRender enabled this may happen during "before handling user events"
-      stat: 1,
-    },
   ],
 };
 
 for (let name of [
   "d3d11layers",
   "d3d9video",
   "glcontext",
   "d3d11video",
--- a/browser/components/dirprovider/DirectoryProvider.cpp
+++ b/browser/components/dirprovider/DirectoryProvider.cpp
@@ -59,26 +59,21 @@ DirectoryProvider::GetFile(const char* a
 static void AppendDistroSearchDirs(nsIProperties* aDirSvc,
                                    nsCOMArray<nsIFile>& array) {
   nsCOMPtr<nsIFile> searchPlugins;
   nsresult rv = aDirSvc->Get(XRE_APP_DISTRIBUTION_DIR, NS_GET_IID(nsIFile),
                              getter_AddRefs(searchPlugins));
   if (NS_FAILED(rv)) return;
   searchPlugins->AppendNative(NS_LITERAL_CSTRING("searchplugins"));
 
-  bool exists;
-  rv = searchPlugins->Exists(&exists);
-  if (NS_FAILED(rv) || !exists) return;
-
   nsCOMPtr<nsIFile> commonPlugins;
   rv = searchPlugins->Clone(getter_AddRefs(commonPlugins));
   if (NS_SUCCEEDED(rv)) {
     commonPlugins->AppendNative(NS_LITERAL_CSTRING("common"));
-    rv = commonPlugins->Exists(&exists);
-    if (NS_SUCCEEDED(rv) && exists) array.AppendObject(commonPlugins);
+    array.AppendObject(commonPlugins);
   }
 
   nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (prefs) {
     nsCOMPtr<nsIFile> localePlugins;
     rv = searchPlugins->Clone(getter_AddRefs(localePlugins));
     if (NS_FAILED(rv)) return;
 
@@ -87,37 +82,31 @@ static void AppendDistroSearchDirs(nsIPr
     nsAutoCString defLocale;
     rv = prefs->GetCharPref("distribution.searchplugins.defaultLocale",
                             defLocale);
     if (NS_SUCCEEDED(rv)) {
       nsCOMPtr<nsIFile> defLocalePlugins;
       rv = localePlugins->Clone(getter_AddRefs(defLocalePlugins));
       if (NS_SUCCEEDED(rv)) {
         defLocalePlugins->AppendNative(defLocale);
-        rv = defLocalePlugins->Exists(&exists);
-        if (NS_SUCCEEDED(rv) && exists) {
-          array.AppendObject(defLocalePlugins);
-          return;  // all done
-        }
+        array.AppendObject(defLocalePlugins);
+        return;  // all done
       }
     }
 
     // we didn't have a defaultLocale, use the user agent locale
     nsAutoCString locale;
     LocaleService::GetInstance()->GetAppLocaleAsLangTag(locale);
 
     nsCOMPtr<nsIFile> curLocalePlugins;
     rv = localePlugins->Clone(getter_AddRefs(curLocalePlugins));
     if (NS_SUCCEEDED(rv)) {
       curLocalePlugins->AppendNative(locale);
-      rv = curLocalePlugins->Exists(&exists);
-      if (NS_SUCCEEDED(rv) && exists) {
-        array.AppendObject(curLocalePlugins);
-        return;  // all done
-      }
+      array.AppendObject(curLocalePlugins);
+      return;  // all done
     }
   }
 }
 
 NS_IMETHODIMP
 DirectoryProvider::GetFiles(const char* aKey, nsISimpleEnumerator** aResult) {
   if (!strcmp(aKey, NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)) {
     nsCOMPtr<nsIProperties> dirSvc(
@@ -161,20 +150,16 @@ DirectoryProvider::AppendingEnumerator::
     if (!mNext) continue;
 
     char const* const* i = mAppendList;
     while (*i) {
       mNext->AppendNative(nsDependentCString(*i));
       ++i;
     }
 
-    bool exists;
-    rv = mNext->Exists(&exists);
-    if (NS_SUCCEEDED(rv) && exists) break;
-
     mNext = nullptr;
   }
 
   return NS_OK;
 }
 
 DirectoryProvider::AppendingEnumerator::AppendingEnumerator(
     nsISimpleEnumerator* aBase, char const* const* aAppendList)
--- a/toolkit/components/search/SearchService.jsm
+++ b/toolkit/components/search/SearchService.jsm
@@ -1057,16 +1057,20 @@ SearchService.prototype = {
         winPattern: "*.xml",
       });
       try {
         // Add dir to distDirs if it contains any files.
         let { done } = await iterator.next();
         if (!done) {
           distDirs.push(dir);
         }
+      } catch (ex) {
+        if (!(ex instanceof OS.File.Error) || !ex.becauseNoSuchFile) {
+          throw ex;
+        }
       } finally {
         iterator.close();
       }
     }
 
     function notInCacheVisibleEngines(engineName) {
       return !cache.visibleDefaultEngines.includes(engineName);
     }