From 2809aeed5e963eba47896e444c93a17454f1e662 Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Fri, 2 Aug 2019 12:46:55 -0700 Subject: [PATCH] Fix crash on resume in RunnableQueue (#1490) --- app/src/main/cpp/native-lib.cpp | 11 ++++++++--- app/src/main/cpp/vrb | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/native-lib.cpp b/app/src/main/cpp/native-lib.cpp index 93f081f02..bbeaf5fbc 100644 --- a/app/src/main/cpp/native-lib.cpp +++ b/app/src/main/cpp/native-lib.cpp @@ -198,7 +198,8 @@ android_main(android_app *aAppState) { // Attach JNI thread JNIEnv *jniEnv; - (*aAppState->activity->vm).AttachCurrentThread(&jniEnv, NULL); + (*aAppState->activity->vm).AttachCurrentThread(&jniEnv, nullptr); + sAppContext->mQueue->InitializeJava(jniEnv); // Create Browser context crow::VRBrowser::InitializeJava(jniEnv, aAppState->activity->clazz); @@ -228,7 +229,7 @@ android_main(android_app *aAppState) { // Loop until all events are read // If the activity is paused use a blocking call to read events. while (ALooper_pollAll(BrowserWorld::Instance().IsPaused() ? -1 : 0, - NULL, + nullptr, &events, (void **) &pSource) >= 0) { // Process event. @@ -236,14 +237,18 @@ android_main(android_app *aAppState) { pSource->process(aAppState, pSource); } + + // Check if we are exiting. if (aAppState->destroyRequested != 0) { sAppContext->mEgl->MakeCurrent(); + sAppContext->mQueue->ProcessRunnables(); BrowserWorld::Instance().ShutdownGL(); BrowserWorld::Instance().ShutdownJava(); BrowserWorld::Destroy(); sAppContext->mEgl->Destroy(); - sAppContext.reset(); + sAppContext->mEgl.reset(); + sAppContext->mDevice.reset(); aAppState->activity->vm->DetachCurrentThread(); return; } diff --git a/app/src/main/cpp/vrb b/app/src/main/cpp/vrb index 91444aa64..17564614d 160000 --- a/app/src/main/cpp/vrb +++ b/app/src/main/cpp/vrb @@ -1 +1 @@ -Subproject commit 91444aa647913a52f3acc566d4d7cae248a7d31b +Subproject commit 17564614d81e5f8e164d382c62fa35d4718e36b1