Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure RunnableQueue is reattached when new render thread starts #2743

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/cpp/Skybox.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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