Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3244)

Unified Diff: base/android/java/src/org/chromium/base/ContextUtils.java

Issue 2242173003: Ignore multiple assignments to global context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/java/src/org/chromium/base/ContextUtils.java
diff --git a/base/android/java/src/org/chromium/base/ContextUtils.java b/base/android/java/src/org/chromium/base/ContextUtils.java
index 4b615cb3ea93160c5d55ad37905335d1a64c17db..f22a5d2436a1b16853efc4019b076bcb2f5cd7b4 100644
--- a/base/android/java/src/org/chromium/base/ContextUtils.java
+++ b/base/android/java/src/org/chromium/base/ContextUtils.java
@@ -54,7 +54,12 @@ public class ContextUtils {
// Conceding that occasionally in tests, native is loaded before the browser process is
// started, in which case the browser process re-sets the application context.
if (sApplicationContext != null && sApplicationContext != appContext) {
- throw new RuntimeException("Attempting to set multiple global application contexts.");
+ // For webview, sometimes the client app overrides getApplicationContext in a poor way
+ // and fails to make it idempotent. We cannot crash in this scenario, so we ignore new
+ // assignments and assume that the first initialized context is the right application
+ // object. See http://crbug.com/637389.
+ Log.e(TAG, "Multiple contexts detected, ignoring new application context.");
boliu 2016/08/15 21:16:38 so this turns off the check for chrome as well, is
Peter Wen 2016/08/15 21:49:54 If we do use separate calls, it would mean using s
boliu 2016/08/15 22:21:32 What do you mean by "large portion of the code bas
boliu 2016/08/15 22:44:03 I mean this is fine. Just feels bad that chrome is
Peter Wen 2016/08/16 13:57:46 It means LibraryLoader, which webview calls and no
+ return;
}
initJavaSideApplicationContext(appContext);
}

Powered by Google App Engine
This is Rietveld 408576698