Bug 755324 - Avoid JNI leak in AndroidGLController::ProvideEGLSurface. r=kats

This commit is contained in:
Geoff Brown 2012-05-15 18:30:15 -04:00
parent 7d366238f9
commit 33db9b1f0b

View File

@ -36,8 +36,11 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "AndroidLayerViewWrapper.h" #include "AndroidLayerViewWrapper.h"
#include "AndroidBridge.h"
#include "nsDebug.h" #include "nsDebug.h"
using namespace mozilla;
#define ASSERT_THREAD() \ #define ASSERT_THREAD() \
NS_ASSERTION(pthread_self() == mThread, "Something is calling AndroidGLController from the wrong thread!") NS_ASSERTION(pthread_self() == mThread, "Something is calling AndroidGLController from the wrong thread!")
@ -77,6 +80,7 @@ void
AndroidGLController::SetGLVersion(int aVersion) AndroidGLController::SetGLVersion(int aVersion)
{ {
ASSERT_THREAD(); ASSERT_THREAD();
AutoLocalJNIFrame jniFrame(mJEnv, 0);
mJEnv->CallVoidMethod(mJObj, jSetGLVersionMethod, aVersion); mJEnv->CallVoidMethod(mJObj, jSetGLVersionMethod, aVersion);
} }
@ -84,6 +88,7 @@ EGLSurface
AndroidGLController::ProvideEGLSurface() AndroidGLController::ProvideEGLSurface()
{ {
ASSERT_THREAD(); ASSERT_THREAD();
AutoLocalJNIFrame jniFrame(mJEnv);
jobject jObj = mJEnv->CallObjectMethod(mJObj, jProvideEGLSurfaceMethod); jobject jObj = mJEnv->CallObjectMethod(mJObj, jProvideEGLSurfaceMethod);
return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField)); return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField));
} }
@ -92,5 +97,6 @@ void
AndroidGLController::WaitForValidSurface() AndroidGLController::WaitForValidSurface()
{ {
ASSERT_THREAD(); ASSERT_THREAD();
AutoLocalJNIFrame jniFrame(mJEnv, 0);
mJEnv->CallVoidMethod(mJObj, jWaitForValidSurfaceMethod); mJEnv->CallVoidMethod(mJObj, jWaitForValidSurfaceMethod);
} }