mirror of
https://github.com/amwatson/CitraVR.git
synced 2024-09-20 03:11:40 +02:00
Fix incorrect deletion of VrUiLayerObject to remove memory error
This commit is contained in:
parent
c68b499ad9
commit
52fd1e1809
2 changed files with 17 additions and 15 deletions
|
@ -249,8 +249,10 @@ void UILayer::Shutdown() {
|
|||
mSwapchain.mHeight = 0;
|
||||
mEnv->DeleteGlobalRef(mVrUILayerClass);
|
||||
mVrUILayerClass = nullptr;
|
||||
mEnv->DeleteGlobalRef(mVrUILayerObject);
|
||||
mVrUILayerClass = nullptr;
|
||||
// These steps are not strictly necessary for app shutdown, as references are cleaned up when
|
||||
// the JVM is destroyed, but memory-saving if this class is destroyed/re-initialized at runtime.
|
||||
mEnv->DeleteLocalRef(mVrUILayerObject);
|
||||
mVrUILayerObject = nullptr;
|
||||
}
|
||||
|
||||
int UILayer::CreateSwapchain() {
|
||||
|
|
|
@ -1052,7 +1052,7 @@ public:
|
|||
, mActivityObjectGlobalRef(jni->NewGlobalRef(activityObject)) {
|
||||
assert(jvm != nullptr);
|
||||
assert(activityObject != nullptr);
|
||||
mThread = std::thread([this]() {ThreadFn();});
|
||||
mThread = std::thread([this]() { ThreadFn(); });
|
||||
}
|
||||
|
||||
~VRAppThread() {
|
||||
|
@ -1066,20 +1066,20 @@ public:
|
|||
|
||||
private:
|
||||
void ThreadFn() {
|
||||
assert(mVm != nullptr);
|
||||
ALOGI("VRAppThread: starting");
|
||||
JNIEnv* jni = nullptr;
|
||||
if (mVm->AttachCurrentThread(&jni, nullptr) != JNI_OK) {
|
||||
FAIL("%s(): Could not attach to mVm", __FUNCTION__);
|
||||
}
|
||||
// Gotta set this after the JNIEnv is attached, or else it'll be
|
||||
// overwritten
|
||||
prctl(PR_SET_NAME, (long)"CVR::Main", 0, 0, 0);
|
||||
assert(mVm != nullptr);
|
||||
ALOGI("VRAppThread: starting");
|
||||
JNIEnv* jni = nullptr;
|
||||
if (mVm->AttachCurrentThread(&jni, nullptr) != JNI_OK) {
|
||||
FAIL("%s(): Could not attach to mVm", __FUNCTION__);
|
||||
}
|
||||
// Gotta set this after the JNIEnv is attached, or else it'll be
|
||||
// overwritten
|
||||
prctl(PR_SET_NAME, (long)"CVR::Main", 0, 0, 0);
|
||||
|
||||
ThreadFnJNI(jni);
|
||||
ThreadFnJNI(jni);
|
||||
|
||||
mVm->DetachCurrentThread();
|
||||
ALOGI("VRAppThread: exited");
|
||||
mVm->DetachCurrentThread();
|
||||
ALOGI("VRAppThread: exited");
|
||||
}
|
||||
|
||||
// All operations assume that the JNIEnv is attached
|
||||
|
|
Loading…
Reference in a new issue