The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Android_JNI_FileRead crashes on android4
Dennis Muratshin
Guest

Hi,
I opened file with SDL_RWFromFile from APK and tried to get it size with:
SDL_RWseek(fh, 0, RW_SEEK_END);
It’s working everywhere except android 4


03-23 12:19:54.464: E/dalvikvm(563): JNI ERROR (app bug): accessed stale local reference 0x1d200029 (index 10 in a table of size 3)
03-23 12:19:54.464: W/dalvikvm(563): JNI WARNING: 0x1d200029 is not a valid JNI reference
03-23 12:19:54.464: W/dalvikvm(563): in Lorg/libsdl/app/SDLActivity;.nativeInit:()V (CallIntMethodV)

I added some traces and found out that app crashes in Android_JNI_FileRead at this line:
int result = mEnv->CallIntMethod(readableByteChannel, readMethod, byteBuffer);

I don’t understand all this JNI magic code, but found this article:
http://android-developers.blogspot.com/2011/11/jni-local-reference-changes-in-ics.html

Who may fix this bug?
Android_JNI_FileRead crashes on android4
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2012/3/25 Dennis Muratshin
Quote:

Hi,
I opened file with SDL_RWFromFile from APK and tried to get it size with:
SDL_RWseek(fh, 0, RW_SEEK_END);
It’s working everywhere except android 4
 
 
03-23 12:19:54.464: E/dalvikvm(563): JNI ERROR (app bug): accessed stale local reference 0x1d200029 (index 10 in a table of size 3)
03-23 12:19:54.464: W/dalvikvm(563): JNI WARNING: 0x1d200029 is not a valid JNI reference
03-23 12:19:54.464: W/dalvikvm(563):              in Lorg/libsdl/app/SDLActivity;.nativeInit:()V (CallIntMethodV)
 
I added some traces and found out that app crashes in Android_JNI_FileRead at this line:
int result = mEnv->CallIntMethod(readableByteChannel, readMethod, byteBuffer);
 
I don’t understand all this JNI magic code, but found this article:
http://android-developers.blogspot.com/2011/11/jni-local-reference-changes-in-ics.html
 
Who may fix this bug?






I believe the minimum supported API level is android-5, and I'm fairly certain there was at least a feature that required android-7 and up, though I can't recall what was it.


--
Gabriel.
Android_JNI_FileRead crashes on android4
Dennis Muratshin
Guest

I meant latest Android 4.0.3 ice cream sandwich
(Android 15 api)

From: [mailto:] On Behalf Of Gabriel Jacobo
Sent: Monday, March 26, 2012 7:57 PM
To: SDL Development List
Subject: Re: [SDL] Android_JNI_FileRead crashes on android4


2012/3/25 Dennis Muratshin
Hi,
I opened file with SDL_RWFromFile from APK and tried to get it size with:
SDL_RWseek(fh, 0, RW_SEEK_END);
It’s working everywhere except android 4


03-23 12:19:54.464: E/dalvikvm(563): JNI ERROR (app bug): accessed stale local reference 0x1d200029 (index 10 in a table of size 3)
03-23 12:19:54.464: W/dalvikvm(563): JNI WARNING: 0x1d200029 is not a valid JNI reference
03-23 12:19:54.464: W/dalvikvm(563): in Lorg/libsdl/app/SDLActivity;.nativeInit:()V (CallIntMethodV)

I added some traces and found out that app crashes in Android_JNI_FileRead at this line:
int result = mEnv->CallIntMethod(readableByteChannel, readMethod, byteBuffer);

I don’t understand all this JNI magic code, but found this article:
http://android-developers.blogspot.com/2011/11/jni-local-reference-changes-in-ics.html

Who may fix this bug?







I believe the minimum supported API level is android-5, and I'm fairly certain there was at least a feature that required android-7 and up, though I can't recall what was it.



--
Gabriel.
Android_JNI_FileRead crashes on android4
Dennis Muratshin
Guest

Anyone answer?
Also I see that this api is not thread safe on Android

From: Dennis Muratshin [mailto:]
Sent: Monday, March 26, 2012 9:26 PM
To: 'SDL Development List'
Subject: RE: [SDL] Android_JNI_FileRead crashes on android4



I meant latest Android 4.0.3 ice cream sandwich
(Android 15 api)

From: [mailto:] ([email][mailto:][/email]) On Behalf Of Gabriel Jacobo
Sent: Monday, March 26, 2012 7:57 PM
To: SDL Development List
Subject: Re: [SDL] Android_JNI_FileRead crashes on android4


2012/3/25 Dennis Muratshin
Hi,
I opened file with SDL_RWFromFile from APK and tried to get it size with:
SDL_RWseek(fh, 0, RW_SEEK_END);
It’s working everywhere except android 4


03-23 12:19:54.464: E/dalvikvm(563): JNI ERROR (app bug): accessed stale local reference 0x1d200029 (index 10 in a table of size 3)
03-23 12:19:54.464: W/dalvikvm(563): JNI WARNING: 0x1d200029 is not a valid JNI reference
03-23 12:19:54.464: W/dalvikvm(563): in Lorg/libsdl/app/SDLActivity;.nativeInit:()V (CallIntMethodV)

I added some traces and found out that app crashes in Android_JNI_FileRead at this line:
int result = mEnv->CallIntMethod(readableByteChannel, readMethod, byteBuffer);

I don’t understand all this JNI magic code, but found this article:
http://android-developers.blogspot.com/2011/11/jni-local-reference-changes-in-ics.html

Who may fix this bug?







I believe the minimum supported API level is android-5, and I'm fairly certain there was at least a feature that required android-7 and up, though I can't recall what was it.



--
Gabriel.
Re: Android_JNI_FileRead crashes on android4
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
Dennis Muratshin wrote:
Anyone answer?
Also I see that this api is not thread safe on Android


Can you try out the patch I've uploaded to http://bugzilla.libsdl.org/show_bug.cgi?id=1500 ?