Closed Bug 1565268 Opened 5 years ago Closed 5 years ago

Immersive mode doesn't exit correctly when exiting after JS execution is paused

Categories

(Core :: WebVR, defect, P2)

70 Branch
defect

Tracking

()

VERIFIED FIXED
mozilla72
Tracking Status
firefox72 --- verified
firefox73 --- verified
firefox74 --- verified

People

(Reporter: imanol.martin, Assigned: daoshengmu)

Details

Attachments

(2 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0

Steps to reproduce:

Test with FxR using immersive_dialog branch https://github.com/MozillaReality/FirefoxReality/tree/immersive_dialog

Actual results:

Immersive mode exits and after the alert is dismissed, the WebVR app is still in immersive mode.
If instead of exiting immersive triggering a prompt, the controller back button is used, immersive mode exits correctly.

It seems that this could happen if immersive is exited after any JS call that triggers a JS execution pause, like alerts or any other prompts.

Expected results:

Immersive mode should be exited correclty same as when using the back button.

The priority flag is not set for this bug.
:kip, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(kgilbert)
Flags: needinfo?(kgilbert)
Priority: -- → P2

will it fix by Bug 1587366? If no, I am going to jump in.

Flags: needinfo?(imanol)

(In reply to Daosheng Mu[:daoshengmu] from comment #2)

will it fix by Bug 1587366? If no, I am going to jump in.

Bug 1587366 doesn't fix this one.

Flags: needinfo?(imanol)

It happens in WebVR desktop either, but in Windows, it is caused by VRService[1] is forced to shutdown because the service doesn't update for a while.

For Android, it is a different story. Android doesn't use VRService. the VRManager will shutdown [2] finally, we can consider to use this new displayInfo to leave the current immersive mode by ExternalVR::StopPresenting in FxR.

[1] https://searchfox.org/mozilla-central/rev/17756e2a5c180d980a4b08d99f8cc0c97290ae8d/gfx/vr/service/VRService.cpp#259
[2] https://searchfox.org/mozilla-central/rev/17756e2a5c180d980a4b08d99f8cc0c97290ae8d/gfx/vr/VRManager.cpp#859.

I think the right fixing place needs to be in Gecko. When VRService is shutdown, we need to figure out how to fire a vm->FireDOMVRDisplayPresentChangeEvent(mDisplayInfo.mDisplayID); event in VRDisplayClient

Assignee: nobody → dmu
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

When the VRService is shutdown, we will create a new VRDisplayClient at [1]. Then, posting vrdisplayconnect event to Globalwindow [2] with the new VRdisplay [3], the previous VRDisplay is removed from VRManagerChild, and it seems like can't receive events more.

However, in JS side, it is still using the previous VRDisplay and its VRDisplayClient. So, we can't submit frames after requesting presenting [4] because its frameId will no longer be updated from new VRDisplayInfo [5].

[1] https://dxr.mozilla.org/mozilla-central/rev/273c3db836e1a2ffdb7ce46d28d85adbbf2b70ba/gfx/vr/ipc/VRManagerChild.cpp#198
[2] https://dxr.mozilla.org/mozilla-central/source/dom/base/nsGlobalWindowInner.cpp#6377
[3] https://dxr.mozilla.org/mozilla-central/rev/273c3db836e1a2ffdb7ce46d28d85adbbf2b70ba/dom/vr/VRDisplay.cpp#98
[4] https://dxr.mozilla.org/mozilla-central/source/gfx/vr/ipc/VRLayerChild.cpp#48
[5] https://dxr.mozilla.org/mozilla-central/rev/273c3db836e1a2ffdb7ce46d28d85adbbf2b70ba/gfx/vr/VRManager.cpp#496

When JS is paused, VRService will automatically shutdown because the timer is not updated, we used to create a new VRDisplay to JS. However, the page is still using the older VRDisplay, so it can't get the newest VRDisplayInfo status. We should exit presentation and apply the VRDisplayInfo status to the original VRDisplay instead of creating new one.

It doesn't work for FxR though. The VRManager::SubmitFrame() stops to be called after a few frames. I am investigating.

(In reply to Daosheng Mu[:daoshengmu] from comment #8)

It doesn't work for FxR though. The VRManager::SubmitFrame() stops to be called after a few frames. I am investigating.

I have confirmed the reason that breaks Android is org.mozilla.vrbrowser E/libEGL: eglMakeCurrent:796 error 300d (EGL_BAD_SURFACE) that makes VRManagerChild::RecvUpdateDisplayInfo can't receive new events from the parent side. That looks like the java::GeckoSurfaceTexture is broken when trying to go back to the immersive mode. So, I think I have to release the VRScreen screenbuffer first.

Attachment #9103377 - Attachment is obsolete: true

When JS is paused, VRService will automatically shutdown because the timer is not updated,
we used to create a new VRDisplay to JS. However, the page is still using the older VRDisplay,
so it can't get the newest VRDisplayInfo status. We should exit presentation and
apply the VRDisplayInfo status to the original VRDisplay instead of creating new one.

Besides, we also need to release the VR screen buffer after exiting the immersive mode to avoid eglMakeCurrent error.

We can remove mDisplayName/Id and just use VRDisplayInfo to get these two values.

Pushed by dmu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4d18e8024acf
Recovering VRDisplay status after VRService is shutdown. r=kip,jgilbert
https://hg.mozilla.org/integration/autoland/rev/b70aa06f74d5
Part 2: Removing mDisplayName/Id from VRDisplay. r=kip
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72

I can confirm this issue is fixed, I verified using Fx 72.0, 73.0b1 and 74.0a1, using Oculus Rift.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: