Bug 1404383 - Delay nsStringBundle preloading in content processes. r=smaug
authorGabor Krizsanits <gkrizsanits@mozilla.com>
Fri, 29 Sep 2017 17:54:06 +0200
changeset 426519 53f147e1524e1f54beb760addc6129b5b7e4ddfc
parent 426518 db05998a8a032109be3afe6066518cdf903c13e0
child 426520 2773796df8a337e5de31811acb4662ce67955f93
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewerssmaug
bugs1404383
milestone58.0a1
Bug 1404383 - Delay nsStringBundle preloading in content processes. r=smaug Early in the startup the channel creation might fail, in nsStringBundle load and any further attempts are prevented which leads to broken ocaization support for the process. Let's wait until the child process learns about the chrome URLs registered on the parent side with the preloads.
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/ipc/ContentChild.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -796,17 +796,19 @@ nsContentUtils::Init()
 
   nsCOMPtr<nsIUUIDGenerator> uuidGenerator =
     do_GetService("@mozilla.org/uuid-generator;1", &rv);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   uuidGenerator.forget(&sUUIDGenerator);
 
-  AsyncPrecreateStringBundles();
+  if (XRE_IsParentProcess()) {
+    AsyncPrecreateStringBundles();
+  }
 
   RefPtr<UserInteractionObserver> uio = new UserInteractionObserver();
   uio->Init();
   uio.forget(&sUserInteractionObserver);
 
   sInitialized = true;
 
   return NS_OK;
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -3198,21 +3198,22 @@ public:
 
   /**
    * Returns true if the passed-in mesasge is a pending InputEvent.
    *
    * @param aMsg  The message to check
    */
   static bool IsMessageInputEvent(const IPC::Message& aMsg);
 
+  static void AsyncPrecreateStringBundles();
+
 private:
   static bool InitializeEventTable();
 
   static nsresult EnsureStringBundle(PropertiesFile aFile);
-  static void AsyncPrecreateStringBundles();
 
   static bool CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
                                 nsIPrincipal* aPrincipal);
 
   static nsresult WrapNative(JSContext *cx, nsISupports *native,
                              nsWrapperCache *cache, const nsIID* aIID,
                              JS::MutableHandle<JS::Value> vp,
                              bool aAllowWrapping);
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2246,16 +2246,21 @@ ContentChild::RecvRegisterChrome(Infalli
                                  const nsCString& locale,
                                  const bool& reset)
 {
   nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
   nsChromeRegistryContent* chromeRegistry =
     static_cast<nsChromeRegistryContent*>(registrySvc.get());
   chromeRegistry->RegisterRemoteChrome(packages, resources, overrides,
                                        locale, reset);
+  static bool preloadDone = false;
+  if (!preloadDone) {
+    preloadDone = true;
+    nsContentUtils::AsyncPrecreateStringBundles();
+  }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvRegisterChromeItem(const ChromeRegistryItem& item)
 {
   nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
   nsChromeRegistryContent* chromeRegistry =