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

Ensure the vrb::RunnableQueue has been created before the Activiy tries to call it in onCreate() #1487

Merged
merged 1 commit into from
Aug 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"