Bug 720400 - Crash in nsPluginInstanceOwner::RemovePluginView @ mozilla::AndroidBridge::EnsureJNIThread [r=blassey]
authorMatt Brubeck <mbrubeck@mozilla.com>
Sat, 28 Jan 2012 20:16:26 -0800
changeset 86904 3a6ece55c68c69dca745889e96707dd0b64d6447
parent 86903 ab3edf81a46f7beebd5c01cdd254df9e16945346
child 86905 59d8d92f9f3c08443ab3437f8eabcf90b1a7a616
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs720400
milestone12.0a1
Bug 720400 - Crash in nsPluginInstanceOwner::RemovePluginView @ mozilla::AndroidBridge::EnsureJNIThread [r=blassey]
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
mobile/xul/app/mobile.js
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -2270,16 +2270,21 @@ nsresult nsPluginHost::ScanPluginsDirect
       if (!aCreatePluginList && *aPluginsChanged)
         break;
     }
     return NS_OK;
 }
 
 nsresult nsPluginHost::LoadPlugins()
 {
+#ifdef ANDROID
+  if (XRE_GetProcessType() == GeckoProcessType_Content) {
+    return NS_OK;
+  }
+#endif
   // do not do anything if it is already done
   // use ReloadPlugins() to enforce loading
   if (mPluginsLoaded)
     return NS_OK;
 
   if (mPluginsDisabled)
     return NS_OK;
 
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1663,30 +1663,33 @@ void nsPluginInstanceOwner::ScrollPositi
     }
   }
 #endif
 }
 
 #ifdef MOZ_WIDGET_ANDROID
 bool nsPluginInstanceOwner::AddPluginView(const gfxRect& aRect)
 {
-  AndroidBridge::AutoLocalJNIFrame frame(1);
-
   void* javaSurface = mInstance->GetJavaSurface();
   if (!javaSurface) {
     mInstance->RequestJavaSurface();
     return false;
   }
 
   if (aRect.IsEqualEdges(mLastPluginRect)) {
     // Already added and in position, no work to do
     return true;
   }
 
   JNIEnv* env = GetJNIForThread();
+  if (!env)
+    return false;
+
+  AndroidBridge::AutoLocalJNIFrame frame(env, 1);
+
   jclass cls = env->FindClass("org/mozilla/gecko/GeckoAppShell");
 
 #ifdef MOZ_JAVA_COMPOSITOR
   nsAutoString metadata;
   nsCOMPtr<nsIAndroidDrawMetadataProvider> metadataProvider =
       AndroidBridge::Bridge()->GetDrawMetadataProvider();
   metadataProvider->GetDrawMetadata(metadata);
 
@@ -1728,39 +1731,41 @@ bool nsPluginInstanceOwner::AddPluginVie
     mPluginViewAdded = true;
   }
 
   return true;
 }
 
 void nsPluginInstanceOwner::RemovePluginView()
 {
-  AndroidBridge::AutoLocalJNIFrame frame(1);
-
   if (mInstance && mObjectFrame && mPluginViewAdded) {
     mPluginViewAdded = false;
 
     void* surface = mInstance->GetJavaSurface();
-    if (surface) {
-      JNIEnv* env = GetJNIForThread();
-      if (env) {
-        jclass cls = env->FindClass("org/mozilla/gecko/GeckoAppShell");
-        jmethodID method = env->GetStaticMethodID(cls,
-                                                  "removePluginView",
-                                                  "(Landroid/view/View;)V");
-        env->CallStaticVoidMethod(cls, method, surface);
-
-        {
-          ANPEvent event;
-          event.inSize = sizeof(ANPEvent);
-          event.eventType = kLifecycle_ANPEventType;
-          event.data.lifecycle.action = kOffScreen_ANPLifecycleAction;
-          mInstance->HandleEvent(&event, nsnull);
-        }
-      }
+    if (!surface)
+      return;
+
+    JNIEnv* env = GetJNIForThread();
+    if (!env)
+      return;
+
+    AndroidBridge::AutoLocalJNIFrame frame(env, 1);
+
+    jclass cls = env->FindClass("org/mozilla/gecko/GeckoAppShell");
+    jmethodID method = env->GetStaticMethodID(cls,
+                                              "removePluginView",
+                                              "(Landroid/view/View;)V");
+    env->CallStaticVoidMethod(cls, method, surface);
+
+    {
+      ANPEvent event;
+      event.inSize = sizeof(ANPEvent);
+      event.eventType = kLifecycle_ANPEventType;
+      event.data.lifecycle.action = kOffScreen_ANPLifecycleAction;
+      mInstance->HandleEvent(&event, nsnull);
     }
   }
 }
 #endif
 
 nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
 {
 #ifdef MOZ_WIDGET_ANDROID
--- a/mobile/xul/app/mobile.js
+++ b/mobile/xul/app/mobile.js
@@ -435,17 +435,17 @@ pref("browser.ui.touch.top", 12);
 pref("browser.ui.touch.bottom", 4);
 pref("browser.ui.touch.weight.visited", 120); // percentage
 
 // plugins
 #if MOZ_PLATFORM_MAEMO == 6
 pref("plugin.disable", false);
 pref("dom.ipc.plugins.enabled", true);
 #elifdef ANDROID
-pref("plugin.disable", false);
+pref("plugin.disable", true);
 pref("dom.ipc.plugins.enabled", false);
 #else
 pref("plugin.disable", true);
 pref("dom.ipc.plugins.enabled", true);
 #endif
 
 // process priority
 // higher values give content process less CPU time