Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 2544753

Browse files
authored
Fix potential duplicated StartFrame() call (#3047)
1 parent 7c64ae7 commit 2544753

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

app/src/main/cpp/BrowserWorld.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,10 +1422,12 @@ BrowserWorld::TickImmersive() {
14221422
m.device->SetRenderMode(device::RenderMode::Immersive);
14231423

14241424
const bool supportsFrameAhead = m.device->SupportsFramePrediction(DeviceDelegate::FramePrediction::ONE_FRAME_AHEAD);
1425+
auto framePrediction = DeviceDelegate::FramePrediction::ONE_FRAME_AHEAD;
14251426
VRB_GL_CHECK(glDepthMask(GL_FALSE));
14261427
if (!supportsFrameAhead || (m.externalVR->GetVRState() != ExternalVR::VRState::Rendering)) {
14271428
// Do not use one frame ahead prediction if not supported or we are rendering the spinner.
1428-
m.device->StartFrame(DeviceDelegate::FramePrediction::NO_FRAME_AHEAD);
1429+
framePrediction = DeviceDelegate::FramePrediction::NO_FRAME_AHEAD;
1430+
m.device->StartFrame(framePrediction);
14291431
m.externalVR->PushFramePoses(m.device->GetHeadTransform(), m.controllers->GetControllers(),
14301432
m.context->GetTimestamp());
14311433
}
@@ -1435,15 +1437,15 @@ BrowserWorld::TickImmersive() {
14351437
m.externalVR->GetFrameResult(surfaceHandle, textureWidth, textureHeight, leftEye, rightEye);
14361438
ExternalVR::VRState state = m.externalVR->GetVRState();
14371439
if (supportsFrameAhead) {
1438-
if (m.externalVR->WasFirstPresentingFrame()) {
1440+
if (framePrediction != DeviceDelegate::FramePrediction::ONE_FRAME_AHEAD) {
14391441
// StartFrame() has been already called to render the spinner, do not call it again.
14401442
// Instead, repeat the XR frame and render the spinner while we transition
14411443
// to one frame ahead prediction.
14421444
state = ExternalVR::VRState::Loading;
14431445
} else {
14441446
// Predict poses for one frame ahead and push the data to shmem so Gecko
14451447
// can start the next XR RAF ASAP.
1446-
m.device->StartFrame(DeviceDelegate::FramePrediction::ONE_FRAME_AHEAD);
1448+
m.device->StartFrame(framePrediction);
14471449
}
14481450
m.externalVR->PushFramePoses(m.device->GetHeadTransform(), m.controllers->GetControllers(),
14491451
m.context->GetTimestamp());

app/src/main/cpp/ExternalVR.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ struct ExternalVR::State {
127127
vrb::Vector eyeOffsets[device::EyeCount];
128128
uint64_t lastFrameId = 0;
129129
bool firstPresentingFrame = false;
130-
bool wasFirstPresentingFrame = false;
131130
bool compositorEnabled = false;
132131
bool waitingForExit = false;
133132

@@ -456,7 +455,6 @@ ExternalVR::WaitFrameResult() {
456455
m.PullBrowserStateWhileLocked();
457456
while (true) {
458457
if (!IsPresenting() || m.browser.layerState[0].layer_stereo_immersive.frameId != m.lastFrameId) {
459-
m.wasFirstPresentingFrame = m.firstPresentingFrame;
460458
m.firstPresentingFrame = false;
461459
m.system.displayState.lastSubmittedFrameSuccessful = true;
462460
m.system.displayState.lastSubmittedFrameId = m.browser.layerState[0].layer_stereo_immersive.frameId;
@@ -482,10 +480,6 @@ ExternalVR::WaitFrameResult() {
482480
return true;
483481
}
484482

485-
bool ExternalVR::WasFirstPresentingFrame() const {
486-
return m.wasFirstPresentingFrame;
487-
}
488-
489483
void
490484
ExternalVR::CompleteEnumeration()
491485
{

app/src/main/cpp/ExternalVR.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class ExternalVR : public ImmersiveDisplay {
5555
VRState GetVRState() const;
5656
void PushFramePoses(const vrb::Matrix& aHeadTransform, const std::vector<Controller>& aControllers, const double aTimestamp);
5757
bool WaitFrameResult();
58-
bool WasFirstPresentingFrame() const;
5958
void GetFrameResult(int32_t& aSurfaceHandle,
6059
int32_t& aTextureWidth,
6160
int32_t& aTextureHeight,

0 commit comments

Comments
 (0)