Commit b0503cf9 authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Ensure that inline sessions can be requested when enable_vr=false

There were a couple of things that were happening that were blocking our
ability to return inline sessions.  The first thing that was happening
was that initial promises would end up hanging.  This is because while
we have a mojo reference to the server, the browser side had nothing
so we would get a disconnect error, which we didn't notify any pending
promises after.  The second issue was that we were always rejecting
sessions if we didn't have a service (i.e. because we hit an error
earlier and caused it to get disconnected).  Finally, we weren't
guarading against the service being null, and could therefore crash
after receiving a disconnect error.

Bug: 944285,936264
Change-Id: I252361877243e9762ba438763ca54b902ee05b37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1548365
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#647075}
parent a74e5c71
...@@ -246,8 +246,10 @@ ScriptPromise XR::requestSession(ScriptState* script_state, ...@@ -246,8 +246,10 @@ ScriptPromise XR::requestSession(ScriptState* script_state,
kFeaturePolicyBlocked)); kFeaturePolicyBlocked));
} }
// If we no longer have a valid service connection reject the request. // If we no longer have a valid service connection reject the request, unless
if (!service_) { // it was for an inline mode. In which case, we'll end up creating the
// session in OnRequestSessionReturned.
if (!service_ && mode != XRSession::kModeInline) {
return ScriptPromise::RejectWithDOMException( return ScriptPromise::RejectWithDOMException(
script_state, DOMException::Create(DOMExceptionCode::kNotFoundError, script_state, DOMException::Create(DOMExceptionCode::kNotFoundError,
kNoDevicesMessage)); kNoDevicesMessage));
...@@ -332,6 +334,11 @@ void XR::EnsureDevice() { ...@@ -332,6 +334,11 @@ void XR::EnsureDevice() {
return; return;
} }
if (!service_) {
OnRequestDeviceReturned(nullptr);
return;
}
service_->RequestDevice( service_->RequestDevice(
WTF::Bind(&XR::OnRequestDeviceReturned, WrapPersistent(this))); WTF::Bind(&XR::OnRequestDeviceReturned, WrapPersistent(this)));
pending_device_ = true; pending_device_ = true;
...@@ -527,6 +534,12 @@ void XR::Dispose() { ...@@ -527,6 +534,12 @@ void XR::Dispose() {
frame_provider_->Dispose(); frame_provider_->Dispose();
device_ = nullptr; device_ = nullptr;
// If we failed out with an outstanding call to RequestDevice, we may have
// pending promises that need to be resolved. Fake a call that we found no
// devices to free up those promises.
if (pending_device_)
OnRequestDeviceReturned(nullptr);
} }
void XR::OnEnvironmentProviderDisconnect() { void XR::OnEnvironmentProviderDisconnect() {
......
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