Fix to Connectivity Bluetooth JNI related crash problem

Review Request #108113 - Created Jan. 3, 2013 and updated

Information
Kate Alhola
android-qt-mobility
unstable
Reviewers
necessitas
vatra
Qt Mobility Bluetooth crashed by JNI originated errors. Two root causes found, JNI vm->getEnv on different thread and missing NewGlobalRef's 
Tested on Samsung S3 and Acer Iconia A100 

Issues

  • 3
  • 0
  • 0
  • 3
Description From Last Updated
Why is it needed to refresh btAdapter? Is the trouble actually the fact that QBluetoothLocalDevicePrivate::initialize is now called from another ... Lauri Laanmets Lauri Laanmets
Only a whitespace change? Could be removed to reduce noise? Lauri Laanmets Lauri Laanmets
NewGlobalRef must also be deleted with DeleteGlobalRef, otherwise garbage collector will never destroy it and Android will have memory leaks. ... Lauri Laanmets Lauri Laanmets
Kate Alhola
Review request changed
Lauri Laanmets

   
OK, that proves that the lib-loading-thread has been changed and the improvement is now more fail-safe. Looks OK but I'm not sure if it is now needed to DetachThread. The reason why this magic here on lines 38-71 is, was to get access to "android/app/Application" and BroadcastReviever.java. It was only possible in JNI_OnLoad because only that function was called by Ministro from the thread with Android App context. That is why "qtApplicationC" is saved and "nativeEnvironment" is passed on. Maybe it's not needed anymore - need to be checked.
Why is it needed to refresh btAdapter? Is the trouble actually the fact that QBluetoothLocalDevicePrivate::initialize is now called from another thread. Maybe missing detach in JNI_OnLoad gives troubles?
Only a whitespace change? Could be removed to reduce noise?
NewGlobalRef must also be deleted with DeleteGlobalRef, otherwise garbage collector will never destroy it and Android will have memory leaks. The exceptions are the ones created once during loading the libs, these will be removed together with the process.
Loading...