Ok, Android and JUCE apps work great for armeabi-v7a.
When I target only x86 to test on my Intel Android tablet I get a crash.
To get this I just APP_ABI := x86 in my Application.mk.
I can run any non-JUCE NDK app and everything is fine, this problem only occurs with JUCE apps (not just mine!).
So, I fired up ndk-gdb and I found that some weird pointer stuff is going on.
Basically on the C++ side @ juce_android_Messaging.cpp MessageManager::postMessageToSystemQueue() a pointer to a message is passed to the Java function postMessage().
This is good, then on the Java side, postMessage() will make a new MessageCallback that is a Runnable object. When it executes with MessageCallback::run(), it passes that pointer value (a long on the Java side) back to C++ with the native function deliverMessage() @ juce_android_Messaging.cpp:50. When I look at this pointer value in the eclipse debugger, it is valid.
The value passed around is supposed to be a 32 bit pointer, but when it is passedd back to C++ from Java it has all 64 bits filled. It seems to have bits swapped. The valid pointer bits are in the high 32 bits and the low 32 are filled with junk. If my pointer looked like 0x12345678 when it was passed Java, when it is returned it looks like 0x123456789abcfef0. The high bits being the only valid ones.
To confirm, inside juce_android_Messaging.cpp::deliverMessage(), I shift the passed in value by 32 bits:
value = value >> 32;
This transforms the value back into the original pointer that was passed to Java in the first place via postMessageToSystemQueue(). I confirmed all of this with a bunch prints.
With this hack, my app seems to have run fine, but I didn't test it too much. I have other tasks so I'm not going to focus on this one, but I'd love to figure out what is going on here. Plus, there could be some other issues with x86 builds if pointers are passed into Java and back to C++.
In the meantime I'll continue to just target ARM.
Any ideas on a proper fix that would be universal? I didn't want to mess with the JNI macros too much.
