Commit 18d41172 authored by Klaus Weidner's avatar Klaus Weidner Committed by Commit Bot

WebXR arcore_device lifecycle cleanup

OnSessionEnded claimed to be safe to be run repeatedly, but it wasn't
quite a no-op. Use VRDeviceBase's session tracking to be clearer about
session lifetime, and only do teardown once.

This is a speculative fix for DCHECK errors in the linked bug, though
I haven't been able to specifically reproduce these.

Bug: 1014159
Change-Id: I800f62bee87a1827d57999af12e721ba06fd3c79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1859832Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705754}
parent 103f20b8
...@@ -122,11 +122,16 @@ void ArCoreDevice::RequestSession( ...@@ -122,11 +122,16 @@ void ArCoreDevice::RequestSession(
DVLOG(1) << __func__; DVLOG(1) << __func__;
DCHECK(IsOnMainThread()); DCHECK(IsOnMainThread());
if (session_state_->pending_request_session_callback_) { if (HasExclusiveSession()) {
DVLOG(1) << __func__ << ": Rejecting additional session request"; DVLOG(1) << __func__ << ": Rejecting additional session request";
std::move(callback).Run(nullptr, mojo::NullRemote()); std::move(callback).Run(nullptr, mojo::NullRemote());
return; return;
} }
// Set HasExclusiveSession status to true. This lasts until OnSessionEnded.
OnStartPresenting();
DCHECK(!session_state_->pending_request_session_callback_);
session_state_->pending_request_session_callback_ = std::move(callback); session_state_->pending_request_session_callback_ = std::move(callback);
bool use_dom_overlay = base::Contains( bool use_dom_overlay = base::Contains(
...@@ -200,6 +205,9 @@ void ArCoreDevice::OnDrawingSurfaceDestroyed() { ...@@ -200,6 +205,9 @@ void ArCoreDevice::OnDrawingSurfaceDestroyed() {
void ArCoreDevice::OnSessionEnded() { void ArCoreDevice::OnSessionEnded() {
DVLOG(1) << __func__; DVLOG(1) << __func__;
if (!HasExclusiveSession())
return;
// This may be a no-op in case session end was initiated from the Java side. // This may be a no-op in case session end was initiated from the Java side.
arcore_session_utils_->EndSession(); arcore_session_utils_->EndSession();
...@@ -225,6 +233,9 @@ void ArCoreDevice::OnSessionEnded() { ...@@ -225,6 +233,9 @@ void ArCoreDevice::OnSessionEnded() {
// Create a new mailbox bridge for use in the next session. (This is cheap, // Create a new mailbox bridge for use in the next session. (This is cheap,
// the constructor doesn't establish a GL context.) // the constructor doesn't establish a GL context.)
mailbox_bridge_ = std::make_unique<vr::MailboxToSurfaceBridge>(); mailbox_bridge_ = std::make_unique<vr::MailboxToSurfaceBridge>();
// This sets HasExclusiveSession status to false.
OnExitPresent();
} }
void ArCoreDevice::CallDeferredRequestSessionCallback(bool success) { void ArCoreDevice::CallDeferredRequestSessionCallback(bool success) {
......
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