Commit 370f9589 authored by Patrick To's avatar Patrick To Committed by Commit Bot

ExitPresent when an OpenXR event indicates that the session has ended.

With the current location of where OpenXR events are processed, Blink is
not notified when the session has ended. When a session ends, there is
first an event to set the visibility state to hidden before the event
indicating the session has ended. Setting the visibility state to
hidden will prevent Blink from requesting anymore frames.

Since XRCompositorCommon:GetFrameData() checks for session ended at
the beginning of the function, before requesting a frame from OpenXR
where events are processed, it never detects that the session has ended
to call ExitPresent.

Moving event processing to OpenXrApiWrapper::HasSessionEnded ensures
that the most current state is returned to XRCompositorCommon.

Bug: 1044641
Change-Id: I0bf5d1ffc810720df6e4a9c37daac4d5d58a77c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2021336
Commit-Queue: Patrick To <patrto@microsoft.com>
Reviewed-by: default avatarRafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736058}
parent 8d794cef
......@@ -235,6 +235,14 @@ XrResult OpenXrApiWrapper::PickEnvironmentBlendMode(XrSystemId system) {
return XR_SUCCESS;
}
bool OpenXrApiWrapper::UpdateAndGetSessionEnded() {
// Ensure we have the latest state from the OpenXR runtime.
if (XR_FAILED(ProcessEvents())) {
DCHECK(session_ended_);
}
return session_ended_;
}
// Callers of this function must check the XrResult return value and destroy
// this OpenXrApiWrapper object on failure to clean up any intermediate
// objects that may have been created before the failure.
......@@ -384,7 +392,7 @@ XrResult OpenXrApiWrapper::BeginFrame(
DCHECK(HasSession());
DCHECK(HasColorSwapChain());
RETURN_IF_XR_FAILED(ProcessEvents());
DCHECK(!session_ended_);
XrFrameWaitInfo wait_frame_info = {XR_TYPE_FRAME_WAIT_INFO};
XrFrameState frame_state = {XR_TYPE_FRAME_STATE};
......
......@@ -44,7 +44,7 @@ class OpenXrApiWrapper {
static VRTestHook* GetTestHook();
bool session_ended() const { return session_ended_; }
bool UpdateAndGetSessionEnded();
XrResult InitSession(const Microsoft::WRL::ComPtr<ID3D11Device>& d3d_device,
std::unique_ptr<OpenXRInputHelper>* input_helper);
......
......@@ -135,7 +135,7 @@ bool OpenXrRenderLoop::PreComposite() {
}
bool OpenXrRenderLoop::HasSessionEnded() {
return openxr_->session_ended();
return openxr_->UpdateAndGetSessionEnded();
}
bool OpenXrRenderLoop::SubmitCompositedFrame() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment