hanshantao / dolphin-player

Automatically exported from code.google.com/p/dolphin-player
0 stars 0 forks source link

JNI ERROR (app bug): attempt to use stale local reference #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
After compiling with API > 14 when running the player we get the error:

E/dalvikvm(6721): JNI ERROR (app bug): attempt to use stale local reference 
0x20900001

There is more info in:

http://android-developers.blogspot.com.es/2011/11/jni-local-reference-changes-in
-ics.html

Original issue reported on code.google.com by pabl...@gmail.com on 8 Sep 2012 at 1:06

GoogleCodeExporter commented 9 years ago
Well I found the solution after playing around with the code:

In SDL_androidvideo.c:

1-In funtion DemoRenderer_nativeInitJavaCallbacks:

*********Orginal********

JavaRenderer = thiz;
JavaRendererClass = (*JavaEnv)->GetObjectClass(JavaEnv, thiz);

*******Modified*********
JavaRenderer = (*JavaEnv)->NewGlobalRef(JavaEnv,thiz);
JavaRendererClass = (*JavaEnv)->GetObjectClass(JavaEnv, JavaRenderer);

2- In CallJavaExitFromNativePlayerView

******Add this to delete the GlobalReference******

(*JavaEnv)->DeleteGlobalRef(JavaEnv,JavaRenderer);

Also consider in SDL_androidaudio.c adding the line:

(*jniEnv)->DeleteGlobalRef(jniEnv, JavaAudioThread);

for example in function ANDROIDAUD_CloseAudio()

Original comment by pabl...@gmail.com on 8 Sep 2012 at 1:40

GoogleCodeExporter commented 9 years ago
For the moment do not add 

(*JavaEnv)->DeleteGlobalRef(JavaEnv,JavaRenderer);

in CallJavaExitFromNativePlayerView

Its causing a JNI_ERROR, I guess must be deleted somewhere else.

Original comment by pabl...@gmail.com on 8 Sep 2012 at 1:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by aatrala on 8 Sep 2012 at 1:53

GoogleCodeExporter commented 9 years ago
This problem is reproducible as mentioned. Above mentioned idea is correct for 
fixing the problem. Needs to be called at exit. Will be fixed in the next 
release.

Original comment by aatrala on 8 Sep 2012 at 1:57

GoogleCodeExporter commented 9 years ago
I think is still necessary to figure out when to call 

(*JavaEnv)->DeleteGlobalRef(JavaEnv,JavaRenderer);

in SDL_androidvideo.c

I tried adding it in CallJavaExitFromNativePlayerView but gives a JNI_ERROR 
error when back button pressed during playing.

Not Deleting globalref doesn't seem to cause a problem

Original comment by pabl...@gmail.com on 8 Sep 2012 at 2:05