Skip to content

Commit

Permalink
Introduce dropFrame in VRBrowserState
Browse files Browse the repository at this point in the history
This patch introduces `dropFrame` in VRBrowserState for chromium
backend to discard the current frame and wait for the next tick of
vsync. Also, this prevents from visiting StartFrame/EndFrame to
keep the current scene when discarding frame.
  • Loading branch information
MyidShin committed Feb 27, 2024
1 parent 4cc8c33 commit a9a9662
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ BrowserWorld::TickImmersive() {
// Instead, repeat the XR frame and render the spinner while we transition
// to one frame ahead prediction.
state = ExternalVR::VRState::Loading;
} else {
} else if (!aDiscardFrame){
// Predict poses for one frame ahead and push the data to shmem so Gecko
// can start the next XR RAF ASAP.
m.device->StartFrame(framePrediction);
Expand Down Expand Up @@ -1841,11 +1841,11 @@ BrowserWorld::TickImmersive() {
DrawImmersive(aEye);
};
}
m.frameEndHandler = [=]() {
m.device->EndFrame(aDiscardFrame ? DeviceDelegate::FrameEndMode::DISCARD : DeviceDelegate::FrameEndMode::APPLY);
m.blitter->EndFrame();
};
}
m.frameEndHandler = [=]() {
m.device->EndFrame(aDiscardFrame ? DeviceDelegate::FrameEndMode::DISCARD : DeviceDelegate::FrameEndMode::APPLY);
m.blitter->EndFrame();
};
} else {
if (surfaceHandle != 0) {
m.blitter->CancelFrame(surfaceHandle);
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/cpp/ExternalVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,14 @@ ExternalVR::WaitFrameResult() {
// VRB_LOG("RequestFrame BREAK %llu", m.browser.layerState[0].layer_stereo_immersive.frameId);
break;
}

#if CHROMIUM
if(m.browser.dropFame) {
m.system.displayState.droppedFrameCount++;
return false;
}
#endif

if (m.firstPresentingFrame || m.waitingForExit) {
return true; // Do not block to show loading screen until the first frame arrives.
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/cpp/moz_external_vr.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ struct VRBrowserState {
bool detectRuntimesOnly;
bool presentationActive;
bool navigationTransitionActive;
#if CHROMIUM
bool dropFame;
#endif
VRLayerState layerState[kVRLayerMaxCount];
VRHapticState hapticState[kVRHapticsMaxCount];

Expand Down

0 comments on commit a9a9662

Please sign in to comment.