Skip to content

Commit

Permalink
Ensure RunnableQueue is reattached when new render thread starts (#2743)
Browse files Browse the repository at this point in the history
Fixes #2739
  • Loading branch information
bluemarvin committed Feb 6, 2020
1 parent 7195a5c commit d2c3be6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/src/main/cpp/Skybox.cpp
Expand Up @@ -113,6 +113,7 @@ struct Skybox::State {
};

VertexArrayPtr array = VertexArray::Create(aContext);
array->SetUVLength(3);
const float kLength = 140.0f;
for (int i = 0; i < cubeVertices.size(); i += 3) {
array->AppendVertex(Vector(-kLength * cubeVertices[i], -kLength * cubeVertices[i + 1],
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/native-lib.cpp
Expand Up @@ -199,7 +199,7 @@ android_main(android_app *aAppState) {
// Attach JNI thread
JNIEnv *jniEnv;
(*aAppState->activity->vm).AttachCurrentThread(&jniEnv, nullptr);
sAppContext->mQueue->InitializeJava(jniEnv);
sAppContext->mQueue->AttachToThread();

// Create Browser context
crow::VRBrowser::InitializeJava(jniEnv, aAppState->activity->clazz);
Expand Down
3 changes: 2 additions & 1 deletion app/src/picovr/cpp/native-lib.cpp
Expand Up @@ -35,6 +35,7 @@ JNI_METHOD(void, nativeOnCreate)
JNI_METHOD(void, nativeInitialize)
(JNIEnv* aEnv, jobject aActivity, jint width, jint height, jobject aAssetManager, jint type, jint focusInex) {
gDestroyed = false;
sQueue->AttachToThread();
if (!sDevice) {
sDevice = crow::DeviceDelegatePicoVR::Create(BrowserWorld::Instance().GetRenderContext());
}
Expand All @@ -55,7 +56,7 @@ JNI_METHOD(void, nativeShutdown)
JNI_METHOD(void, nativeDestroy)
(JNIEnv*, jobject) {
gDestroyed = true;
sQueue->ProcessRunnables();
sQueue->Clear();
BrowserWorld::Instance().ShutdownJava();
BrowserWorld::Instance().RegisterDeviceDelegate(nullptr);
sDevice = nullptr;
Expand Down
8 changes: 8 additions & 0 deletions app/src/wavevr/cpp/native-lib.cpp
Expand Up @@ -43,6 +43,7 @@ JNI_METHOD(void, activityResumed)
}

int main(int argc, char *argv[]) {
sQueue->AttachToThread();
VRB_LOG("Call WVR_Init");
WVR_InitError eError = WVR_Init(WVR_AppType_VRContent);
if (eError != WVR_InitError_None) {
Expand Down Expand Up @@ -87,7 +88,14 @@ int main(int argc, char *argv[]) {
VRB_GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
BrowserWorld::Instance().Draw();
}
BrowserWorld::Instance().RegisterDeviceDelegate(nullptr);
sDevice = nullptr;
BrowserWorld::Instance().ShutdownGL();
BrowserWorld::Instance().ShutdownJava();
sQueue->Clear();
sJavaInitialized = false;
BrowserWorld::Destroy();
WVR_Quit();
return 0;
}

Expand Down

0 comments on commit d2c3be6

Please sign in to comment.