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

Commit e9c03ea

Browse files
MortimerGorobluemarvin
authored andcommitted
Ensure that vrPrefsWorkAround method is called before creating the Gecko Runtime (#3654)
1 parent 4ca1220 commit e9c03ea

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ protected void attachBaseContext(Context base) {
228228

229229
@Override
230230
protected void onCreate(Bundle savedInstanceState) {
231-
Bundle extras = getIntent() != null ? getIntent().getExtras() : null;
232-
SessionStore.prefOverrides(this, extras);
233231
((VRBrowserApplication)getApplication()).onActivityCreate(this);
234232
SettingsStore.getInstance(getBaseContext()).setPid(Process.myPid());
235233
// Fix for infinite restart on startup crashes.

app/src/common/shared/org/mozilla/vrbrowser/VRBrowserApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.mozilla.vrbrowser.browser.Places;
1818
import org.mozilla.vrbrowser.browser.Services;
1919
import org.mozilla.vrbrowser.browser.engine.EngineProvider;
20+
import org.mozilla.vrbrowser.browser.engine.SessionStore;
2021
import org.mozilla.vrbrowser.db.AppDatabase;
2122
import org.mozilla.vrbrowser.db.DataRepository;
2223
import org.mozilla.vrbrowser.downloads.DownloadsManager;
@@ -52,6 +53,7 @@ public void onCreate() {
5253
return;
5354
}
5455

56+
SessionStore.prefOverrides(this);
5557
TelemetryWrapper.init(this, EngineProvider.INSTANCE.getDefaultClient(this));
5658
GleanMetricsService.init(this, EngineProvider.INSTANCE.getDefaultClient(this));
5759
}

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/EngineProvider.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ object EngineProvider {
5858
return runtime!!
5959
}
6060

61+
@Synchronized
62+
fun isRuntimeCreated(): Boolean {
63+
return runtime != null
64+
}
65+
6166
fun createGeckoWebExecutor(context: Context): GeckoWebExecutor {
6267
return GeckoWebExecutor(getOrCreateRuntime(context))
6368
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ private SessionStore() {
8787
mSessions = new ArrayList<>();
8888
}
8989

90-
public static void prefOverrides(Context context, Bundle aExtras) {
90+
public static void prefOverrides(Context context) {
9191
// FIXME: Once GeckoView has a prefs API
92-
SessionUtils.vrPrefsWorkAround(context, aExtras);
92+
SessionUtils.vrPrefsWorkAround(context);
9393
}
9494

9595
public void initialize(Context context) {

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ public static boolean isLocalizedContent(@Nullable String url) {
2525
return url != null && (url.startsWith("about:") || url.startsWith("data:"));
2626
}
2727

28-
public static void vrPrefsWorkAround(Context aContext, Bundle aExtras) {
28+
public static void vrPrefsWorkAround(Context aContext) {
29+
if (EngineProvider.INSTANCE.isRuntimeCreated()) {
30+
throw new IllegalStateException("vrPrefsWorkAround must be called before creating the runtime");
31+
}
32+
2933
File path = GeckoProfile.initFromArgs(aContext, null).getDir();
3034
String prefFileName = path.getAbsolutePath() + File.separator + "user.js";
3135
Log.i(LOGTAG, "Creating file: " + prefFileName);
@@ -52,18 +56,6 @@ public static void vrPrefsWorkAround(Context aContext, Bundle aExtras) {
5256
} else {
5357
out.write("user_pref(\"webgl.msaa-force\", false);\n".getBytes());
5458
}
55-
if (BuildConfig.DEBUG) {
56-
int processCount = SettingsStore.getInstance(aContext).isMultiE10s() ? 3 : 1;
57-
out.write(("user_pref(\"dom.ipc.processCount\", " + processCount + ");\n").getBytes());
58-
addOptionalPref(out, "dom.vr.require-gesture", aExtras);
59-
addOptionalPref(out, "privacy.reduceTimerPrecision", aExtras);
60-
if (aExtras != null && aExtras.getBoolean("media.autoplay.enabled", false)) {
61-
// Enable playing audios without gesture (used for gfx automated testing)
62-
out.write("user_pref(\"media.autoplay.enabled.user-gestures-needed\", false);\n".getBytes());
63-
out.write("user_pref(\"media.autoplay.enabled.ask-permission\", false);\n".getBytes());
64-
out.write("user_pref(\"media.autoplay.default\", 0);\n".getBytes());
65-
}
66-
}
6759
} catch (FileNotFoundException e) {
6860
Log.e(LOGTAG, "Unable to create file: '" + prefFileName + "' got exception: " + e.toString());
6961
} catch (IOException e) {

0 commit comments

Comments
 (0)