The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

external/jnipp: Check and re-assign JNIEnv

Fixes a crash when resumed from launcher.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2226>

authored by

Hui Xu and committed by
Marge Bot
cdb9c38e 5b8edfbb

+16 -2
+4 -1
doc/changes/misc_fixes/mr.2200.md
··· 1 - jnipp: Update to fix issues including CTS crashes. 1 + --- 2 + - mr.2226 3 + --- 4 + jnipp: Update/patch to fix issues, including crashes.
+12 -1
src/external/jnipp/jnipp.cpp
··· 156 156 157 157 #endif // _WIN32 158 158 159 + static bool isEnvChanged(JavaVM* vm, ScopedEnv& threadLocalEnv) { 160 + if (vm == nullptr) 161 + { 162 + return false; 163 + } 164 + JNIEnv *curEnv = nullptr; 165 + getEnv(vm, &curEnv); 166 + return curEnv != threadLocalEnv.get(); 167 + } 168 + 169 + 159 170 JNIEnv* env() 160 171 { 161 172 static thread_local ScopedEnv env; 162 173 163 - if (env.get() != nullptr && !isAttached(javaVm)) 174 + if (env.get() != nullptr && (!isAttached(javaVm) || isEnvChanged(javaVm, env))) 164 175 { 165 176 // we got detached, so clear it. 166 177 // will be re-populated from static javaVm below.