Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Ensure the vrb::RunnableQueue has been created before the Activiy tri…
Browse files Browse the repository at this point in the history
…es to call it in onCreate() (#1487)
  • Loading branch information
bluemarvin authored and MortimerGoro committed Aug 2, 2019
1 parent 3d484cb commit 648c8c4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ android_main(android_app *aAppState) {
(*aAppState->activity->vm).AttachCurrentThread(&jniEnv, NULL);

// Create Browser context
sAppContext = std::make_shared<AppContext>();
sAppContext->mQueue = vrb::RunnableQueue::Create(aAppState->activity->vm);
crow::VRBrowser::InitializeJava(jniEnv, aAppState->activity->clazz);

// Create device delegate
Expand Down Expand Up @@ -265,6 +263,8 @@ JNI_METHOD(void, queueRunnable)
(JNIEnv *aEnv, jobject, jobject aRunnable) {
if (sAppContext) {
sAppContext->mQueue->AddRunnable(aEnv, aRunnable);
} else {
VRB_ERROR("Failed to queue Runnable from UI thread. Render thread AppContext has not been initialized.")
}
}

Expand All @@ -276,4 +276,15 @@ JNI_METHOD(jboolean, platformExit)
return (jboolean) false;
}

jint JNI_OnLoad(JavaVM* aVm, void*) {
sAppContext = std::make_shared<AppContext>();
sAppContext->mQueue = vrb::RunnableQueue::Create(aVm);
return JNI_VERSION_1_6;
}

void JNI_OnUnload(JavaVM* vm, void* reserved) {
sAppContext = nullptr;
}


} // extern "C"

0 comments on commit 648c8c4

Please sign in to comment.