Bug 1507324 - 1. Keep current remote type if possible; r=geckoview-reviewers,snorp
authorJim Chen <nchen@mozilla.com>
Wed, 14 Nov 2018 23:39:21 +0000
changeset 502898 950e5bdaedf1771ee1c1962d513bbb5a04b621ae
parent 502897 7f4d0af1b7b4f73d877a1e0fe0ff3e82c5c360c4
child 502899 b77bc550ca99c11516dbad53afb8a16be2a10196
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, snorp
bugs1507324
milestone65.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 1507324 - 1. Keep current remote type if possible; r=geckoview-reviewers,snorp Some pages can be either remote or non-remote depending on the current remote type, so we need to take that into account when updating the remote type. Differential Revision: https://phabricator.services.mozilla.com/D11951
mobile/android/chrome/geckoview/geckoview.js
mobile/android/modules/geckoview/GeckoViewNavigation.jsm
--- a/mobile/android/chrome/geckoview/geckoview.js
+++ b/mobile/android/chrome/geckoview/geckoview.js
@@ -102,51 +102,56 @@ var ModuleManager = {
   get settings() {
     return this._frozenSettings;
   },
 
   forEach(aCallback) {
     this._modules.forEach(aCallback, this);
   },
 
-  updateRemoteType(aRemoteType) {
-    debug `updateRemoteType remoteType=${aRemoteType}`;
-
-    const currentRemoteType = this.browser.getAttribute("remoteType") || E10SUtils.NOT_REMOTE;
+  updateRemoteTypeForURI(aURI) {
+    const currentType =
+        this.browser.getAttribute("remoteType") || E10SUtils.NOT_REMOTE;
+    const remoteType = E10SUtils.getRemoteTypeForURI(
+        aURI, this.settings.useMultiprocess,
+        currentType, this.browser.currentURI);
 
-    if (aRemoteType && !this.settings.useMultiprocess) {
-      warn `Tried to create a remote browser in multiprocess mode`;
-      return false;
-    }
+    debug `updateRemoteType: uri=${aURI} currentType=${currentType}
+                             remoteType=${remoteType}`;
 
-    if (currentRemoteType === aRemoteType) {
+    if (currentType === remoteType) {
       // We're already using a child process of the correct type.
       return false;
     }
 
+    if (remoteType !== E10SUtils.NOT_REMOTE &&
+        !this.settings.useMultiprocess) {
+      warn `Tried to create a remote browser in non-multiprocess mode`;
+      return false;
+    }
+
     // Now we're switching the remoteness (value of "remote" attr).
-    debug `updateRemoteType: changing from '${currentRemoteType}' to '${aRemoteType}'`;
 
     this.forEach(module => {
       if (module.enabled && module.impl) {
         module.impl.onDisable();
       }
     });
 
     this.forEach(module => {
       if (module.impl) {
         module.impl.onDestroyBrowser();
       }
     });
 
     const parent = this.browser.parentNode;
     this.browser.remove();
-    if (aRemoteType) {
+    if (remoteType) {
       this.browser.setAttribute("remote", "true");
-      this.browser.setAttribute("remoteType", aRemoteType);
+      this.browser.setAttribute("remoteType", remoteType);
     } else {
       this.browser.setAttribute("remote", "false");
       this.browser.removeAttribute("remoteType");
     }
 
     this.forEach(module => {
       if (module.impl) {
         module.impl.onInitBrowser();
--- a/mobile/android/modules/geckoview/GeckoViewNavigation.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewNavigation.jsm
@@ -5,17 +5,16 @@
 "use strict";
 
 var EXPORTED_SYMBOLS = ["GeckoViewNavigation"];
 
 ChromeUtils.import("resource://gre/modules/GeckoViewModule.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
-  E10SUtils: "resource://gre/modules/E10SUtils.jsm",
   Utils: "resource://gre/modules/sessionstore/Utils.jsm",
   LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.jsm",
   Services: "resource://gre/modules/Services.jsm",
 });
 
 // Handles navigation requests between Gecko and a GeckoView.
 // Handles GeckoView:GoBack and :GoForward requests dispatched by
 // GeckoView.goBack and .goForward.
@@ -73,19 +72,17 @@ class GeckoViewNavigation extends GeckoV
           navFlags |= Ci.nsIWebNavigation.LOAD_FLAGS_EXTERNAL;
         }
 
         if (flags & (1 << 3)) {
           navFlags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_POPUPS;
         }
 
         if (this.settings.useMultiprocess) {
-          const remoteType =
-            E10SUtils.getRemoteTypeForURI(uri, true);
-          this.moduleManager.updateRemoteType(remoteType);
+          this.moduleManager.updateRemoteTypeForURI(uri);
         }
 
         let parsedUri;
         let triggeringPrincipal;
         try {
             parsedUri = Services.io.newURI(uri);
             if (parsedUri.schemeIs("about") || parsedUri.schemeIs("data") ||
                 parsedUri.schemeIs("file") || parsedUri.schemeIs("resource")) {
@@ -118,22 +115,22 @@ class GeckoViewNavigation extends GeckoV
     debug `receiveMessage: ${aMsg.name}`;
 
     switch (aMsg.name) {
       case "Browser:LoadURI":
         // This is triggered by E10SUtils.redirectLoad(), and means
         // we may need to change the remoteness of our browser and
         // load the URI.
         const { uri, flags, referrer, triggeringPrincipal } = aMsg.data.loadOptions;
-        const remoteType =
-          E10SUtils.getRemoteTypeForURI(uri, this.settings.useMultiprocess);
+
+        this.moduleManager.updateRemoteTypeForURI(uri);
 
-        this.moduleManager.updateRemoteType(remoteType);
-        this.browser.loadURI(aMsg.data.loadOptions.uri, {
-          flags, referrerURI: referrer,
+        this.browser.loadURI(uri, {
+          flags,
+          referrerURI: referrer,
           triggeringPrincipal: Utils.deserializePrincipal(triggeringPrincipal),
         });
         break;
     }
   }
 
   waitAndSetupWindow(aSessionId, { opener, nextTabParentId }) {
     if (!aSessionId) {