Implement DMABufSurface::GetAsSourceSurface.
Categories
(Core :: Widget: Gtk, defect, P2)
Tracking
()
People
(Reporter: emilio, Assigned: stransky)
References
(Depends on 1 open bug)
Details
Attachments
(3 files, 2 obsolete files)
So that Canvas.drawImage(<video>) does draw an image as expected. I started writing some patches for this, but turns out it's a bit more complicated and I'm not too familiar with the media stack, so I'm going to post them here, but I don't think they're quite ready for review.
| Reporter | ||
Comment 1•4 years ago
|
||
So I think this works some of the time, other times by the time we try to read back the image, ReleaseDMABuf has been called already from the media decoder thread. Martin, do you know what is the best way to proceed here?
| Reporter | ||
Comment 2•4 years ago
|
||
| Reporter | ||
Comment 3•4 years ago
|
||
Mostly taken from CreateSourceSurfaceFromLockedMacIOSurface.
Depends on D115820
Updated•4 years ago
|
| Reporter | ||
Updated•4 years ago
|
Updated•4 years ago
|
| Reporter | ||
Updated•4 years ago
|
| Assignee | ||
Comment 4•4 years ago
•
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #1)
So I think this works some of the time, other times by the time we try to read back the image, ReleaseDMABuf has been called already from the media decoder thread. Martin, do you know what is the best way to proceed here?
When VA-API decoding is used, the DMABuf surfaces are re-used by decoder. VAAPI decoder allocates ~10-15 dmabuf surfaces internally and
exports them as decoded frames. We create DMABufSurfaceYUV wrapper over it but the dmabuf surface is owned by decoder. When we get the frame decoded into dmabuf surface, we export it as DMABufSurfaceYUV object to gecko/layout engine and use 'GlobalRef' functions to track its usage. As the dmabuf memory is shared across processes and we need to protect the data when any gecko component needs it. We use global lock for it, see 'GlobalRef' functions at DMABufSurface.h:
void GlobalRefCountCreate();
bool IsGlobalRefSet() const;
void GlobalRefAdd();
void GlobalRefRelease();
I expect the ReleaseDMABuf() is called here, right?
https://searchfox.org/mozilla-central/rev/08f063f4c89d270fd809fc0325b5a9000ae87d63/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#716
And the surface state is tracked here:
https://searchfox.org/mozilla-central/rev/08f063f4c89d270fd809fc0325b5a9000ae87d63/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h#79
So if you want to keep the DMABufSurfaceYUV around you need to call GlobalRefAdd() on it and then use GlobalRefRelease() when you're finished.
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Comment 5•4 years ago
|
||
Emilio, the patches look good to me.
Moving to gfx as the code involved seems to be touched for gfx folks more often than media. Feel free to ping/move back if I've overlooked something.
| Assignee | ||
Comment 7•4 years ago
|
||
Emilio, do we need to implement it? I see the WhatsApp is working now.
Thanks.
| Assignee | ||
Comment 8•4 years ago
|
||
Okay, I managed to get a testcase at https://jsfiddle.net/onigetoc/v80khg1L/ so I'll look at it.
| Assignee | ||
Updated•4 years ago
|
| Reporter | ||
Comment 9•4 years ago
|
||
Yeah, whatsapp will work but the gif preview will be black.
| Assignee | ||
Comment 10•4 years ago
|
||
Thanks. According to https://gitlab.gnome.org/GNOME/mutter/-/issues/1736 we should not map dmabuf directly by mmap (at least not the buffers we get from VA-API). So we need to map them as textures and use GL context fetch pixels.
| Assignee | ||
Comment 11•4 years ago
|
||
Updated•4 years ago
|
| Assignee | ||
Comment 12•4 years ago
|
||
Add a new param aForFrameRecycle to VideoFrameSurfaceVAAPI::ReleaseVAAPIData(). When it's set, release
all DMABuf surface internal data as the surface is going to be used for another frame.
When VideoFrameSurfaceVAAPI is deleted (for instance when decoder quits) underlying DMABuf surface may be still
used by layout code so don't release surface data in such case but wait to DMABuf surface destructor.
Depends on D116411
| Assignee | ||
Comment 13•4 years ago
|
||
gfx::Factory::CopyDataSourceSurface() was updated so LOCAL_GL_RGBA readFormat and LOCAL_GL_UNSIGNED_BYTE readType is already supported.
Depends on D118302
Updated•4 years ago
|
Comment 14•4 years ago
|
||
Comment 15•4 years ago
|
||
| bugherder | ||
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Updated•4 years ago
|
Comment 16•4 years ago
|
||
| Assignee | ||
Updated•4 years ago
|
Comment 17•4 years ago
|
||
Comment 18•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/f9f8ec6565f5
https://hg.mozilla.org/mozilla-central/rev/001fa442c03e
Updated•4 years ago
|
Updated•4 years ago
|
Comment 19•4 years ago
|
||
The patch landed in nightly and beta is affected.
:stransky, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.
For more information, please visit auto_nag documentation.
Updated•4 years ago
|
Description
•