Hi everyone, I think there’s something fundamentally wrong in the RWOps
backend for Android. There’s been quite a few fixes for it in the last few
months (threading problems, file seeking problems, etc), but I’m afraid
when combined with SDL_ttf something inside Android just gives up…
To anyone interested in verifying this, I’m testing with this APK I built (
http://mdqinc.com/com.mdqinc.bunnymarkx.apk), it’s a “Bunnymark” sort of
app, it shows bunnies jumping around to see how many it can display…when
it works.
The problem started when I added an on screen counter which shows the
number of bunnies, using SDL_ttf. When I try to load the font, I get a
deadlock. It’s not always in the same spot, and, to make this a bonafide
hardcore bug, a very few times (one out of 20 runs maybe), it doesn’t
happen at all…but at least in my ICS loaded Asus Transformer TF101 it
happens fairly consistently.
Most of the locks happen when calling:
jobject byteBuffer = mEnv->NewDirectByteBuffer(buffer, bytesRemaining);
or
int result = mEnv->CallIntMethod(readableByteChannel, readMethod,
byteBuffer);
Which clearly points out (at least to me) to a problem inside the Java VM.
I’ve added a “FileSeek counter” in the APK that counts the number of times
Android_JNI_FileSeek is called, most of the deadlocks happen when the
counter is between 99 and 105, a fairly consistent number as well.
Strangely enough, I’ve never had this issue with SDL_image, I believe this
is due to the way Freetype operates, going forward and backward on the file
several times.
If this is a fundamental issue with the Android JNI stuff, I don’t think
there’s other way around it that loading the font file entirely in memory
and pointing RWOps to that buffer…and that certainly leaves open the
question of what other library can make the Android system deadlock like
this.
If anyone can test the APK and send me feedback about it (you got to
monitor the adb logcat | grep SDL output when it’s running) or any idea on
how to make a proper fix for this problem, I’ll appreciate it.–
Gabriel.