From 3b25125f992036bb02e9d5d2c2a8b50b037b8ca2 Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Thu, 14 Nov 2019 06:28:22 -0800 Subject: [PATCH] Enable e10s by default. Fixes #451 (#2197) --- .../mozilla/vrbrowser/VRBrowserActivity.java | 2 +- .../vrbrowser/browser/SettingsStore.java | 6 +++--- .../vrbrowser/browser/engine/Session.java | 9 +++----- .../browser/engine/SessionSettings.java | 21 +------------------ .../browser/engine/SessionStore.java | 4 ++-- .../settings/DeveloperOptionsView.java | 2 +- app/src/main/res/values/non_L10n.xml | 2 +- 7 files changed, 12 insertions(+), 34 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index 8252feab6..5bc093f26 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -510,7 +510,7 @@ void loadFromIntent(final Intent intent) { boolean enabled = extras.getBoolean("e10s", wasEnabled); if (wasEnabled != enabled) { SettingsStore.getInstance(this).setMultiprocessEnabled(enabled); - SessionStore.get().setMultiprocess(enabled); + SessionStore.get().resetMultiprocess(); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java index 960ecc5b3..f9b1d85b8 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java @@ -47,7 +47,7 @@ SettingsStore getInstance(final @NonNull Context aContext) { public final static boolean REMOTE_DEBUGGING_DEFAULT = false; public final static boolean CONSOLE_LOGS_DEFAULT = false; public final static boolean ENV_OVERRIDE_DEFAULT = false; - public final static boolean MULTIPROCESS_DEFAULT = false; + public final static boolean MULTIPROCESS_DEFAULT = true; public final static boolean PERFORMANCE_MONITOR_DEFAULT = true; public final static boolean DRM_PLAYBACK_DEFAULT = false; public final static boolean TRACKING_DEFAULT = true; @@ -225,12 +225,12 @@ public void setEnvironmentOverrideEnabled(boolean isEnabled) { public boolean isMultiprocessEnabled() { return mPrefs.getBoolean( - mContext.getString(R.string.settings_key_multiprocess), MULTIPROCESS_DEFAULT); + mContext.getString(R.string.settings_key_multiprocess_e10s), MULTIPROCESS_DEFAULT); } public void setMultiprocessEnabled(boolean isEnabled) { SharedPreferences.Editor editor = mPrefs.edit(); - editor.putBoolean(mContext.getString(R.string.settings_key_multiprocess), isEnabled); + editor.putBoolean(mContext.getString(R.string.settings_key_multiprocess_e10s), isEnabled); editor.commit(); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java index b0dbfcc8d..5bf88e528 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java @@ -388,7 +388,7 @@ private SessionState createSession(@NonNull SessionSettings aSettings, @SessionO private GeckoSession createGeckoSession(@NonNull SessionSettings aSettings) { GeckoSessionSettings geckoSettings = new GeckoSessionSettings.Builder() - .useMultiprocess(aSettings.isMultiprocessEnabled()) + .useMultiprocess(SettingsStore.getInstance(mContext).isMultiprocessEnabled()) .usePrivateMode(mUsePrivateMode) .useTrackingProtection(aSettings.isTrackingProtectionEnabled()) .userAgentMode(aSettings.getUserAgentMode()) @@ -743,11 +743,8 @@ public void setUaMode(int mode) { mState.mSession.loadUri(overrideUri != null ? overrideUri : mState.mUri, GeckoSession.LOAD_FLAGS_BYPASS_CACHE | GeckoSession.LOAD_FLAGS_REPLACE_HISTORY); } - protected void setMultiprocess(final boolean aEnabled) { - if (mState.mSettings.isMultiprocessEnabled() != aEnabled) { - mState.mSettings.setMultiprocessEnabled(aEnabled); - recreateSession(); - } + protected void resetMultiprocess() { + recreateSession(); } protected void setTrackingProtection(final boolean aEnabled) { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java index 27395dcd5..608105a57 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java @@ -8,7 +8,6 @@ class SessionSettings { - private boolean isMultiprocessEnabled; private boolean isTrackingProtectionEnabled; private boolean isSuspendMediaWhenInactiveEnabled; private int userAgentMode; @@ -17,7 +16,6 @@ class SessionSettings { private String userAgentOverride; private SessionSettings(@NotNull Builder builder) { - this.isMultiprocessEnabled = builder.isMultiprocessEnabled; this.isTrackingProtectionEnabled = builder.isTrackingProtectionEnabled; this.isSuspendMediaWhenInactiveEnabled = builder.isSuspendMediaWhenInactiveEnabled; this.userAgentMode = builder.userAgentMode; @@ -26,14 +24,6 @@ private SessionSettings(@NotNull Builder builder) { this.userAgentOverride = builder.userAgentOverride; } - public boolean isMultiprocessEnabled() { - return isMultiprocessEnabled; - } - - public void setMultiprocessEnabled(boolean enabled) { - isMultiprocessEnabled = enabled; - } - public boolean isTrackingProtectionEnabled() { return isTrackingProtectionEnabled; } @@ -76,7 +66,6 @@ public void setServoEnabled(boolean enabled) { public static class Builder { - private boolean isMultiprocessEnabled; private boolean isTrackingProtectionEnabled; private boolean isSuspendMediaWhenInactiveEnabled; private int userAgentMode; @@ -87,10 +76,6 @@ public static class Builder { public Builder() { } - public Builder withMultiprocess(boolean isMultiprocessEnabled){ - this.isMultiprocessEnabled = isMultiprocessEnabled; - return this; - } public Builder withTrackingProteccion(boolean isTrackingProtectionEnabled){ this.isTrackingProtectionEnabled = isTrackingProtectionEnabled; @@ -128,7 +113,6 @@ public Builder withDefaultSettings(Context context) { GeckoSessionSettings.VIEWPORT_MODE_DESKTOP : GeckoSessionSettings.VIEWPORT_MODE_MOBILE; return new SessionSettings.Builder() - .withMultiprocess(SettingsStore.getInstance(context).isMultiprocessEnabled()) .withTrackingProteccion(SettingsStore.getInstance(context).isTrackingProtectionEnabled()) .withSuspendMediaWhenInactive(true) .withUserAgent(ua) @@ -137,10 +121,7 @@ public Builder withDefaultSettings(Context context) { } public SessionSettings build(){ - SessionSettings settings = new SessionSettings(this); - - return settings; - + return new SessionSettings(this); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java index 4bcca26f9..436b73dab 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java @@ -237,9 +237,9 @@ public void setUaMode(final int mode) { } } - public void setMultiprocess(final boolean aEnabled) { + public void resetMultiprocess() { for (Session session: mSessions) { - session.setMultiprocess(aEnabled); + session.resetMultiprocess(); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java index 43df28e03..e7e0aa505 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java @@ -160,7 +160,7 @@ private void setMultiprocess(boolean value, boolean doApply) { SettingsStore.getInstance(getContext()).setMultiprocessEnabled(value); if (doApply) { - SessionStore.get().setMultiprocess(value); + SessionStore.get().resetMultiprocess(); } } diff --git a/app/src/main/res/values/non_L10n.xml b/app/src/main/res/values/non_L10n.xml index 215b66be0..d486d0743 100644 --- a/app/src/main/res/values/non_L10n.xml +++ b/app/src/main/res/values/non_L10n.xml @@ -11,7 +11,7 @@ settings_remote_debugging settings_console_logs settings_environment_override - settings_environment_multiprocess + settings_environment_multiprocess_e10s settings_performance_monitor settings_environment_servo settings_key_drm_playback