Closed Bug 1541749 Opened 7 years ago Closed 7 years ago

drawing a video to canvas with drawImage throws 'NS_ERROR_NOT_AVAILABLE' error

Categories

(Core :: Graphics: Canvas2D, defect)

66 Branch
ARM
Android
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1526207

People

(Reporter: pdille, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36

Steps to reproduce:

Attempt to draw a video to canvas.

A fairly simple demo can be found here:
http://html5doctor.com/demos/video-canvas-magic/demo1.html

Click the play button to begin.

View the page source to see the code in question.

Actual results:

When you press the play button, the video plays but nothing is drawn to the canvas, which is the background to the page.

A 'NS_ERROR_NOT_AVAILABLE:' is thrown in the dev console.

Expected results:

When you hit play, the video tag should play and then the background behind it (which is the canvas) should show the same content.

This correctly happens in Firefox 66 on desktop, as well as Chrome on Android.

In which version you are having the error? I am testing in latest Nightly and the background is drawn as expected. Moreover I don't get any error message in the console. Could you please try Nightly and tell us if it works for you? Thank you

Flags: needinfo?(pdille)

Sorry, thought I selected Firefox 66 when I was initially creating this report. I was testing in the latest public Android version, which is 66.0.2 for me.

Just tried now with a Nightly build for Android - 68.0a1 (2019-04-03) and I still don't see the background canvas updating as the video plays. Also tried the Beta version for Android - 67.0b7 - and same problem seen there.

I was connecting over USB with the WebIDE on my desktop to see console output from my Android device, which is how I captured that error message.

I'm using a Pixel 2, running Android 8.1.0

Thanks!

Flags: needinfo?(pdille)
OS: Unspecified → Android
Hardware: Unspecified → ARM

Then my testing was wrong, I missed completely that this was android and I was testing on desktop. So, on android it does not work here too.

Component: Audio/Video → Canvas: 2D
Product: Firefox for Android → Core
Version: Firefox 66 → 66 Branch

It looks like drawImage() fails because SurfaceTextureImage doesn't support GetAsSourceSurface()[1]. Therefore no source surface from the element can be created [2] and it throws error at [3].

[1] https://searchfox.org/mozilla-central/source/gfx/layers/GLImages.h#47
[2] https://searchfox.org/mozilla-central/source/layout/base/nsLayoutUtils.cpp#7513
[3] https://searchfox.org/mozilla-central/source/dom/canvas/CanvasRenderingContext2D.cpp#4342

(In reply to John Lin [:jhlin][:jolin] from comment #4)

It looks like drawImage() fails because SurfaceTextureImage doesn't support GetAsSourceSurface()[1]. Therefore no source surface from the element can be created [2] and it throws error at [3].

[1] https://searchfox.org/mozilla-central/source/gfx/layers/GLImages.h#47
[2] https://searchfox.org/mozilla-central/source/layout/base/nsLayoutUtils.cpp#7513
[3] https://searchfox.org/mozilla-central/source/dom/canvas/CanvasRenderingContext2D.cpp#4342

Does the comment in the code for the first link you gave imply that video to canvas isn't planned to be supported in Firefox on Android at this time? That would be a shame if that's the case.

Tested today on iOS 12 (using ipad mini 4) and Firefox on there was correctly drawing video to canvas. I suppose this is because Firefox on iOS is technically using WebKit rather than Gecko though.

This is a dup of bug 1526207 (there is probably an older bug on file too). The problem is indeed that SurfaceTextureImage doesn't support GetAsSourceSurface. That's because surface textures can only be consumed by one process (so fixing for e10s is very hard), and even within a single process (for fennec) it's difficult to use from multiple gl contexts.

Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.