Bug 731288 - Don't call methods on finalized SurfaceTexture, JNI housekeeping r=blassey

This commit is contained in:
James Willcox 2012-05-21 21:35:29 -04:00
parent 012f67499d
commit 3814700c00
2 changed files with 13 additions and 11 deletions

View File

@ -415,6 +415,19 @@ nsNPAPIPluginInstance::Start()
// before returning. If the plugin returns failure, we'll clear it out below.
mRunning = RUNNING;
#if MOZ_WIDGET_ANDROID
// Flash creates some local JNI references during initialization (NPP_New). It does not
// remove these references later, so essentially they are leaked. AutoLocalJNIFrame
// prevents this by pushing a JNI frame. As a result, all local references created
// by Flash are contained in this frame. AutoLocalJNIFrame pops the frame once we
// go out of scope and the local references are deleted, preventing the leak.
JNIEnv* env = AndroidBridge::GetJNIEnv();
if (!env)
return NS_ERROR_FAILURE;
mozilla::AutoLocalJNIFrame frame(env);
#endif
nsresult newResult = library->NPP_New((char*)mimetype, &mNPP, (PRUint16)mode, count, (char**)names, (char**)values, NULL, &error);
mInPluginInitCall = oldVal;

View File

@ -134,17 +134,6 @@ public class SurfaceTextureLayer extends Layer implements SurfaceTexture.OnFrame
@Override
protected void finalize() throws Throwable {
try {
if (mSurfaceTexture != null) {
try {
SurfaceTexture.class.getDeclaredMethod("release").invoke(mSurfaceTexture);
} catch (NoSuchMethodException nsme) {
Log.e(LOGTAG, "error finding release method on mSurfaceTexture", nsme);
} catch (IllegalAccessException iae) {
Log.e(LOGTAG, "error invoking release method on mSurfaceTexture", iae);
} catch (Exception e) {
Log.e(LOGTAG, "some other exception while invoking release method on mSurfaceTexture", e);
}
}
if (mTextureId > 0)
TextureReaper.get().add(mTextureId);
} finally {