Closed Bug 1492554 Opened Last year Closed Last year

Not composited canvas doesn't work in WebVR

Categories

(Core :: WebVR, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
geckoview62 --- wontfix
firefox63 --- wontfix
firefox64 --- fixed

People

(Reporter: imanol, Assigned: imanol)

References

Details

(Whiteboard: [geckoview:fxr:p1])

Attachments

(1 file)

If we don't add a canvas to the DOM and use it in VR, FxR always renders a black screen. I tried the same on Oculus Go and it works ok.

Also related problem in Firefox Reality. In Hubs (or WebVR link traversal) there is a race condition in which the canvas is not composited because when we enter VR we pause the FxR compositor. As Hubs (or link traversal) doesn't show the final canvas in a WebGL 2D scene before entering VR, the change of this issue happening is higher.

Once a canvas is composited once (HTMLCanvasElement::GetCanvasLayer called), we can remove it from the DOM and it works ok during the WebVR session.

I tested this on Android. It may happen also on desktop, I'll try it.
Whiteboard: [geckoview:fxr:p1]
Imanol, snorp recommends talking to Lee Salzman on the gfx team.
Lee, do you know why this could happen?

We are using a WebGL canvas for WebVR, the problem is that when it's not composited at least once  (e.g. not added to the DOM) all the SurfaceTextures are black, with not apparent errors. WebGL content seems right (checked via readPixels). The thing is that once the canvas is composited once., then it works ok even if removed from DOM again.

Do you now if skia/compositor does something? eg. the target texture might be lazily created, etc
Flags: needinfo?(lsalzman)
(In reply to Imanol Fernandez from comment #2)
> Lee, do you know why this could happen?
> 
> We are using a WebGL canvas for WebVR, the problem is that when it's not
> composited at least once  (e.g. not added to the DOM) all the
> SurfaceTextures are black, with not apparent errors. WebGL content seems
> right (checked via readPixels). The thing is that once the canvas is
> composited once., then it works ok even if removed from DOM again.
> 
> Do you now if skia/compositor does something? eg. the target texture might
> be lazily created, etc

I am confused. You mention WebGL, Skia, canvas, and possibly 2D, but are you talking about Canvas2D, or something else? WebGL doesn't use Skia, and accelerated layers wouldn't be compositing it with Skia either. This would all be going through OpenGL. Can you be more specific about what's going on here, and what components are involved?
Flags: needinfo?(lsalzman)
Sorry for the confusion. I was talking about WebGL only, not Canvas2D. We thought that skia may still be involved someway for layers... But I continued the research and found that it happens because WebGLContext::InitializeCanvasRenderer is only called when 2D compositor renders it for the first time. I confirmed that the problem happens on destkop too (tested on Windows)

I found a workaround trying to mimic what WebGLContext::InitializeCanvasRenderer does internally when we use the WebGLCanvas in that situation. I'll upload a patch soon.
WebGL canvases not composited (e.g. not added to the DOM) don't work in WebVR. WebGLContext::InitializeCanvasRenderer is only called when 2D compositor renders a WebGL canvas for the first time. I tried to mimic what InitializeCanvasRenderer does internally as a workaround.
I've confirmed that this fixes the issue on Windows as well (Tested in OpenVR with a Windows MR headset).

Thanks for fixing this, Imanol!
Comment on attachment 9012214 [details]
Bug 1492554 - Make not composited WebGL canvas work with WebVR

:kip (Kearwood Gilbert) has approved the revision.
Attachment #9012214 - Flags: review+
Assignee: nobody → imanol
Comment on attachment 9012214 [details]
Bug 1492554 - Make not composited WebGL canvas work with WebVR

Jeff Gilbert [:jgilbert] has approved the revision.
Attachment #9012214 - Flags: review+
Pushed by rbarker@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9dbf3ababbfe
Make not composited WebGL canvas work with WebVR r=kip,jgilbert
https://hg.mozilla.org/mozilla-central/rev/9dbf3ababbfe
Status: NEW → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Depends on: 1499758
You need to log in before you can comment on or make changes to this bug.