Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit c87cc72

Browse files
authored
Developer switch for enabling experimental multi-e10s (#3022)
1 parent 09d76ae commit c87cc72

6 files changed

Lines changed: 45 additions & 1 deletion

File tree

app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
8484
public final static long FXA_LAST_SYNC_NEVER = 0;
8585
public final static boolean RESTORE_TABS_ENABLED = true;
8686
public final static boolean BYPASS_CACHE_ON_RELOAD = false;
87+
public final static boolean MULTI_E10S = false;
8788

8889
// Enable telemetry by default (opt-out).
8990
public final static boolean CRASH_REPORTING_DEFAULT = false;
@@ -666,12 +667,22 @@ public boolean isRestoreTabsEnabled() {
666667

667668
public void setBypassCacheOnReload(boolean isEnabled) {
668669
SharedPreferences.Editor editor = mPrefs.edit();
669-
editor.putBoolean(mContext.getString(R.string.settings_key_bypass_cache_on_reload),isEnabled);
670+
editor.putBoolean(mContext.getString(R.string.settings_key_bypass_cache_on_reload), isEnabled);
670671
editor.commit();
671672
}
672673

673674
public boolean isBypassCacheOnReloadEnabled() {
674675
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_bypass_cache_on_reload), BYPASS_CACHE_ON_RELOAD);
675676
}
677+
678+
public void setMultiE10s(boolean isEnabled) {
679+
SharedPreferences.Editor editor = mPrefs.edit();
680+
editor.putBoolean(mContext.getString(R.string.settings_key_multi_e10s), isEnabled);
681+
editor.commit();
682+
}
683+
684+
public boolean isMultiE10s() {
685+
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_multi_e10s), MULTI_E10S);
686+
}
676687
}
677688

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public static void vrPrefsWorkAround(Context aContext, Bundle aExtras) {
4343
// Disable WebRender until it works with FxR
4444
out.write("pref(\"gfx.webrender.force-disabled\", true);\n".getBytes());
4545
out.write("pref(\"signon.rememberSignons\", false);\n".getBytes());
46+
int processCount = SettingsStore.getInstance(aContext).isMultiE10s() ? 3 : 1;
47+
out.write(("pref(\"dom.ipc.processCount\", " + processCount + ");\n").getBytes());
4648
int msaa = SettingsStore.getInstance(aContext).getMSAALevel();
4749
if (msaa > 0) {
4850
int msaaLevel = msaa == 2 ? 4 : 2;

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ protected void updateUI() {
6969
mBinding.bypassCacheOnReloadSwitch.setOnCheckedChangeListener(mBypassCacheOnReloadListener);
7070
setBypassCacheOnReload(SettingsStore.getInstance(getContext()).isBypassCacheOnReloadEnabled(), false);
7171

72+
mBinding.multiE10sSwitch.setOnCheckedChangeListener(mMultiE10sListener);
73+
setMultiE10s(SettingsStore.getInstance(getContext()).isMultiE10s(), false);
74+
7275
if (BuildConfig.DEBUG) {
7376
mBinding.debugLoggingSwitch.setVisibility(View.GONE);
7477
} else {
@@ -108,6 +111,10 @@ protected void updateUI() {
108111
setBypassCacheOnReload(value, doApply);
109112
};
110113

114+
private SwitchSetting.OnCheckedChangeListener mMultiE10sListener = (compundButton, value, doApply) -> {
115+
setMultiE10s(value, doApply);
116+
};
117+
111118
private SwitchSetting.OnCheckedChangeListener mServoListener = (compoundButton, b, doApply) -> {
112119
setServo(b, true);
113120
};
@@ -215,6 +222,17 @@ private void setBypassCacheOnReload(boolean value, boolean doApply) {
215222
}
216223
}
217224

225+
private void setMultiE10s(boolean value, boolean doApply) {
226+
mBinding.multiE10sSwitch.setOnCheckedChangeListener(null);
227+
mBinding.multiE10sSwitch.setValue(value, false);
228+
mBinding.multiE10sSwitch.setOnCheckedChangeListener(mMultiE10sListener);
229+
230+
if (doApply) {
231+
SettingsStore.getInstance(getContext()).setMultiE10s(value);
232+
showRestartDialog();
233+
}
234+
}
235+
218236
private void setServo(boolean value, boolean doApply) {
219237
mBinding.servoSwitch.setOnCheckedChangeListener(null);
220238
mBinding.servoSwitch.setValue(value, false);

app/src/main/res/layout/options_developer.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
android:layout_height="wrap_content"
7474
app:description="@string/bypass_cache_on_reload_switch" />
7575

76+
<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
77+
android:id="@+id/multi_e10s_switch"
78+
android:layout_width="match_parent"
79+
android:layout_height="wrap_content"
80+
app:description="@string/multi_e10s_switch" />
81+
7682
<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
7783
android:id="@+id/servo_switch"
7884
android:layout_width="match_parent"

app/src/main/res/values/non_L10n.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<string name="settings_key_fxa_last_sync" translatable="false">settings_key_fxa_last_sync</string>
5252
<string name="settings_key_restore_tabs" translatable="false">settings_key_restore_tabs</string>
5353
<string name="settings_key_bypass_cache_on_reload" translatable="false">settings_key_bypass_cache_on_reload</string>
54+
<string name="settings_key_multi_e10s" translatable="false">settings_key_multi_e10s</string>
5455
<string name="environment_override_help_url" translatable="false">https://github.com/MozillaReality/FirefoxReality/wiki/Environments</string>
5556
<string name="private_policy_url" translatable="false">https://www.mozilla.org/privacy/firefox/</string>
5657
<string name="private_report_url" translatable="false">https://mixedreality.mozilla.org/fxr/report?src=browser-fxr&amp;label=browser-firefox-reality&amp;url=%1$s</string>

app/src/main/res/values/strings.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@
367367
-->
368368
<string name="bypass_cache_on_reload_switch">Enable Cache Bypass On Reload</string>
369369

370+
<!-- This string labels an On/Off switch in the developer options dialog and is used to toggle
371+
Multi-e10s. Multi-e10s allocates a process for each open window instead of having only one
372+
process for all windows.
373+
-->
374+
<string name="multi_e10s_switch">Enable Multi-e10s</string>
375+
370376
<!-- The string labels an On/Off switch in the developer options dialog and is used to toggle enabling Servo. -->
371377
<string name="developer_options_servo">Enable Servo</string>
372378

0 commit comments

Comments
 (0)