Skip to content

Commit

Permalink
Supress ExternalVR frames when Application is paused (#3054)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Mar 26, 2020
1 parent e083e4b commit 088db73
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,15 @@ void
BrowserWorld::Pause() {
ASSERT_ON_RENDER_THREAD();
m.paused = true;
m.externalVR->OnPause();
m.monitor->Pause();
}

void
BrowserWorld::Resume() {
ASSERT_ON_RENDER_THREAD();
m.paused = false;
m.externalVR->OnResume();
m.monitor->Resume();
}

Expand Down
24 changes: 23 additions & 1 deletion app/src/main/cpp/ExternalVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ ExternalVR::WaitFrameResult() {
// VRB_LOG("RequestFrame BREAK %llu", m.browser.layerState[0].layer_stereo_immersive.frameId);
break;
}
if (m.firstPresentingFrame) {
if (m.firstPresentingFrame || m.waitingForExit) {
return true; // Do not block to show loading screen until the first frame arrives.
}
// VRB_LOG("RequestFrame ABOUT TO WAIT FOR FRAME %llu %llu",m.browser.layerState[0].layer_stereo_immersive.frameId, m.lastFrameId);
Expand Down Expand Up @@ -519,6 +519,28 @@ ExternalVR::SetHapticState(ControllerContainerPtr aControllerContainer) const {
}
}

void
ExternalVR::OnPause() {
if (m.system.displayState.presentingGeneration == 0) {
// Do not call PushSystemState() until correctly initialized.
// Fixes WebXR Display not found error due to some superfluous pause/resume life cycle events.
return;
}
m.system.displayState.isConnected = false;
PushSystemState();
}

void
ExternalVR::OnResume() {
if (m.system.displayState.presentingGeneration == 0) {
// Do not call PushSystemState() until correctly initialized.
// Fixes WebXR Display not found error due to some superfluous pause/resume life cycle events.
return;
}
m.system.displayState.isConnected = true;
PushSystemState();
}

void
ExternalVR::StopPresenting() {
m.system.displayState.presentingGeneration++;
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/cpp/ExternalVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class ExternalVR : public ImmersiveDisplay {
void SetHapticState(ControllerContainerPtr aControllerContainer) const;
void StopPresenting();
void SetSourceBrowser(VRBrowserType aBrowser);
void OnPause();
void OnResume();
ExternalVR();
~ExternalVR() = default;
protected:
Expand Down

0 comments on commit 088db73

Please sign in to comment.