Skip to content

Commit

Permalink
Developer switch for enabling experimental multi-e10s (#3022)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin committed Mar 23, 2020
1 parent 09d76ae commit c87cc72
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
public final static long FXA_LAST_SYNC_NEVER = 0;
public final static boolean RESTORE_TABS_ENABLED = true;
public final static boolean BYPASS_CACHE_ON_RELOAD = false;
public final static boolean MULTI_E10S = false;

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

public void setBypassCacheOnReload(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_bypass_cache_on_reload),isEnabled);
editor.putBoolean(mContext.getString(R.string.settings_key_bypass_cache_on_reload), isEnabled);
editor.commit();
}

public boolean isBypassCacheOnReloadEnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_bypass_cache_on_reload), BYPASS_CACHE_ON_RELOAD);
}

public void setMultiE10s(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_multi_e10s), isEnabled);
editor.commit();
}

public boolean isMultiE10s() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_multi_e10s), MULTI_E10S);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static void vrPrefsWorkAround(Context aContext, Bundle aExtras) {
// Disable WebRender until it works with FxR
out.write("pref(\"gfx.webrender.force-disabled\", true);\n".getBytes());
out.write("pref(\"signon.rememberSignons\", false);\n".getBytes());
int processCount = SettingsStore.getInstance(aContext).isMultiE10s() ? 3 : 1;
out.write(("pref(\"dom.ipc.processCount\", " + processCount + ");\n").getBytes());
int msaa = SettingsStore.getInstance(aContext).getMSAALevel();
if (msaa > 0) {
int msaaLevel = msaa == 2 ? 4 : 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ protected void updateUI() {
mBinding.bypassCacheOnReloadSwitch.setOnCheckedChangeListener(mBypassCacheOnReloadListener);
setBypassCacheOnReload(SettingsStore.getInstance(getContext()).isBypassCacheOnReloadEnabled(), false);

mBinding.multiE10sSwitch.setOnCheckedChangeListener(mMultiE10sListener);
setMultiE10s(SettingsStore.getInstance(getContext()).isMultiE10s(), false);

if (BuildConfig.DEBUG) {
mBinding.debugLoggingSwitch.setVisibility(View.GONE);
} else {
Expand Down Expand Up @@ -108,6 +111,10 @@ protected void updateUI() {
setBypassCacheOnReload(value, doApply);
};

private SwitchSetting.OnCheckedChangeListener mMultiE10sListener = (compundButton, value, doApply) -> {
setMultiE10s(value, doApply);
};

private SwitchSetting.OnCheckedChangeListener mServoListener = (compoundButton, b, doApply) -> {
setServo(b, true);
};
Expand Down Expand Up @@ -215,6 +222,17 @@ private void setBypassCacheOnReload(boolean value, boolean doApply) {
}
}

private void setMultiE10s(boolean value, boolean doApply) {
mBinding.multiE10sSwitch.setOnCheckedChangeListener(null);
mBinding.multiE10sSwitch.setValue(value, false);
mBinding.multiE10sSwitch.setOnCheckedChangeListener(mMultiE10sListener);

if (doApply) {
SettingsStore.getInstance(getContext()).setMultiE10s(value);
showRestartDialog();
}
}

private void setServo(boolean value, boolean doApply) {
mBinding.servoSwitch.setOnCheckedChangeListener(null);
mBinding.servoSwitch.setValue(value, false);
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/options_developer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
android:layout_height="wrap_content"
app:description="@string/bypass_cache_on_reload_switch" />

<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
android:id="@+id/multi_e10s_switch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:description="@string/multi_e10s_switch" />

<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
android:id="@+id/servo_switch"
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<string name="settings_key_fxa_last_sync" translatable="false">settings_key_fxa_last_sync</string>
<string name="settings_key_restore_tabs" translatable="false">settings_key_restore_tabs</string>
<string name="settings_key_bypass_cache_on_reload" translatable="false">settings_key_bypass_cache_on_reload</string>
<string name="settings_key_multi_e10s" translatable="false">settings_key_multi_e10s</string>
<string name="environment_override_help_url" translatable="false">https://github.com/MozillaReality/FirefoxReality/wiki/Environments</string>
<string name="private_policy_url" translatable="false">https://www.mozilla.org/privacy/firefox/</string>
<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>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@
-->
<string name="bypass_cache_on_reload_switch">Enable Cache Bypass On Reload</string>

<!-- This string labels an On/Off switch in the developer options dialog and is used to toggle
Multi-e10s. Multi-e10s allocates a process for each open window instead of having only one
process for all windows.
-->
<string name="multi_e10s_switch">Enable Multi-e10s</string>

<!-- The string labels an On/Off switch in the developer options dialog and is used to toggle enabling Servo. -->
<string name="developer_options_servo">Enable Servo</string>

Expand Down

0 comments on commit c87cc72

Please sign in to comment.