diff --git a/app/src/main/cpp/native-lib.cpp b/app/src/main/cpp/native-lib.cpp index 30ed53b01..92c317ef5 100644 --- a/app/src/main/cpp/native-lib.cpp +++ b/app/src/main/cpp/native-lib.cpp @@ -238,6 +238,7 @@ android_main(android_app *aAppState) { if (aAppState->destroyRequested != 0) { sAppContext->mEgl->MakeCurrent(); sAppContext->mQueue->ProcessRunnables(); + sAppContext->mDevice->OnDestroy(); BrowserWorld::Instance().ShutdownGL(); BrowserWorld::Instance().ShutdownJava(); BrowserWorld::Destroy(); diff --git a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp index 6a17208b5..8bdf55d77 100644 --- a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp +++ b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp @@ -1236,6 +1236,16 @@ DeviceDelegateOculusVR::EnterVR(const crow::BrowserEGLContext& aEGLContext) { void DeviceDelegateOculusVR::LeaveVR() { + if (m.ovr) { + vrapi_LeaveVrMode(m.ovr); + m.ovr = nullptr; + } + m.currentFBO = nullptr; + m.previousFBO = nullptr; +} + +void +DeviceDelegateOculusVR::OnDestroy() { for (OculusLayerPtr& layer: m.uiLayers) { layer->Destroy(); } @@ -1253,13 +1263,6 @@ DeviceDelegateOculusVR::LeaveVR() { vrapi_DestroyTextureSwapChain(m.clearColorSwapChain); m.clearColorSwapChain = nullptr; } - m.currentFBO = nullptr; - m.previousFBO = nullptr; - - if (m.ovr) { - vrapi_LeaveVrMode(m.ovr); - m.ovr = nullptr; - } } bool diff --git a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.h b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.h index 483dfdacf..a68cdbdcf 100644 --- a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.h +++ b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.h @@ -57,6 +57,7 @@ class DeviceDelegateOculusVR : public DeviceDelegate { // Custom methods for NativeActivity render loop based devices. void EnterVR(const crow::BrowserEGLContext& aEGLContext); void LeaveVR(); + void OnDestroy(); bool IsInVRMode() const; bool ExitApp(); protected: