Sorry, forgot to mention I also try using env->IsSameObject(m_jwListener, NULL) to check if the reference is deleted, but still no luck.
Testing devices: Nexus 5, Nexus 6 Best Regard,? ===? Yu-Hsin Hung, Intern, Mediatek Graduate Student,?Institute of Computer Science and Engineering, National Chiao-Tung Universiry, Hsinchu 300, Taiwan? (Phone) +886911012113 (Email)?hungys at hotmail.com? (LinkedIn)?https://www.linkedin.com/in/hungys === ? 2015?8?18? ? 21:57:17, Yu-Hsin Hung (hungys at hotmail.com) ?: Dear devs, Recently I found that when Android client sends GET request to server frequently (e.g. polling), there will be random crashes due to JNI level being aborted. The exception basically says the native code try to access deleted weak global reference. After tracing the implementation, I found that the event listener for GET/POST/PUT/? is stored as weak global references, which means they may be?released by JVM GC on demand and then cause the crashes. iotivity/android/android_api/base/jni/JniOnGetListener.cpp jobject jListener = env->NewLocalRef(m_jwListener); In the above code, the m_jwListener is a weak global reference, so it may be deleted by GC before this line called. But it seems the ART runtime didn?t return NULL as expected, but aborting the execution. Even if I try to modify them as global reference using NewGlobalRef at the constructer of JniOnGetListener (as following), sometimes the crash still occurs. iotivity/android/android_api/base/jni/JniOnGetListener.h jweak m_jwListener; iotivity/android/android_api/base/jni/JniOnGetListener.cpp m_jwListener = env->NewWeakGlobalRef(jListener); The error log is attached. Does anyone notice this issue? or any idea to fix it? Thanks! Best Regard,? ===? Yu-Hsin Hung, Intern, Mediatek Graduate Student,?Institute of Computer Science and Engineering, National Chiao-Tung Universiry, Hsinchu 300, Taiwan? (Phone) +886911012113 (Email)?hungys at hotmail.com? (LinkedIn)?https://www.linkedin.com/in/hungys === -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20150818/ef33cd14/attachment.html>
