Closed
Bug 1206708
Opened 9 years ago
Closed 8 years ago
WebRTC video is doing copying video frames more than it needs to
Categories
(Core :: WebRTC: Audio/Video, defect, P2)
Core
WebRTC: Audio/Video
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
backlog | webrtc/webaudio+ |
People
(Reporter: nical, Assigned: pehrsons)
References
Details
(Keywords: perf)
Attachments
(2 files)
:padenot was looking at some profiles to understand the high cpu usage when using hello on mac and noticed that we go throught TextureClient::UpdateYCbCr on the ImageBridge thread. This means that the Image object that is used with ImageContainer::SetCurrentImage is not implemented on top of TextureClient, and that when comes the time to send the video frame to the compositor, we go through the slow path for each frame: we allocate a new texture and copy the image into it both those things are pretty slow. We can do better by using an Image implementation that is implemented on top of TextureClient so that it can be sent to the compositor without an extra allocation + copy (for instance SharedPlanarYCbCrImage).
Comment 1•9 years ago
|
||
Sounds great - is there a pointer to some code that has an implementation of this?
backlog: --- → webrtc/webaudio+
Rank: 18
Priority: -- → P1
Reporter | ||
Comment 2•9 years ago
|
||
(In reply to Randell Jesup [:jesup] from comment #1) > Sounds great - is there a pointer to some code that has an implementation of > this? So I don't know what Image class is being used with webrtc on mac, but the way the "classic" video pipeline selects the proper image type is by asking the ImageContainer to create it (ImageContainer::CreateImage calls ImageClient::CreateImage, which creates the Shared<Blah>Image class depending on the image format. for instance here: https://dxr.mozilla.org/mozilla-central/rev/9ed17db42e3e46f1c712e4dffd62d54e915e0fac/dom/media/MediaData.cpp#321 So I would look at where the Image object is created, whether it uses ImageContainer::CreateImage or if it does its own thing. If it does the former, it's probably that ImageContainer::CreateImage falls back to a non-shared version of the Image. If things work in the end, you should not take this branch anymore: https://dxr.mozilla.org/mozilla-central/rev/9ed17db42e3e46f1c712e4dffd62d54e915e0fac/gfx/layers/client/ImageClient.cpp#174 It's possible that there are some other less obvious prerequisites that failed and we end up in the slow path in ImageClient.cpp (in this case the starting point of the investigation would be that branch), but it's most likely that we don't create the right Image type.
Updated•9 years ago
|
Reporter | ||
Comment 3•9 years ago
|
||
summary from teh quick discussion in Orlando: Places where copying yuv frames occur: * MappedYCbCrTextureData::CopyInto * YCbCrImageDataSerializer::CopyData Look into RecyclingPlanarYCbCrImage. Usually, if we use a SharedPlanarYCbCrImage instead, it'll avoid a copy.
Reporter | ||
Updated•9 years ago
|
Assignee: nobody → rjesup
Comment 4•8 years ago
|
||
We should also try to integrate this with the "native" image support in webrtc.org videoframes, which is designed to minimize copying and keep stuff in gfxmem as much as possible (and leverage that when HW encoders or decoders are in use)
Assignee | ||
Comment 5•8 years ago
|
||
This avoids expensive copying when compositing these frames on e10s. Review commit: https://reviewboard.mozilla.org/r/45465/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/45465/
Attachment #8741341 -
Flags: review?(rjesup)
Attachment #8741341 -
Flags: review?(nical.bugzilla)
Attachment #8741342 -
Flags: review?(rjesup)
Assignee | ||
Comment 6•8 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/46399/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/46399/
Assignee | ||
Comment 7•8 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=da5e30ca94c6 Mostly good. Though this triggers a known shutdown issue that we'll need to resolve before landing. With Nightly, when profiling on talky.io talking to another machine-local (other process) peer, this patch save us 7% of the samples spent doing work. That is, the thread sending frames to the compositor uses 6.5% of all samples, compared to 13.5% when it has to copy the frames. Other copies happening to/from webrtc.org code are still occurring like before. We should file another bug for integrating the frame types.
Assignee: rjesup → pehrsons
Status: NEW → ASSIGNED
Reporter | ||
Comment 8•8 years ago
|
||
Comment on attachment 8741341 [details] MozReview Request: Bug 1206708 - Make all WebRTC ImageContainers async. r?nical,jesup https://reviewboard.mozilla.org/r/45465/#review42975
Attachment #8741341 -
Flags: review?(nical.bugzilla) → review+
Updated•8 years ago
|
Attachment #8741341 -
Flags: review?(rjesup) → review+
Comment 9•8 years ago
|
||
Comment on attachment 8741341 [details] MozReview Request: Bug 1206708 - Make all WebRTC ImageContainers async. r?nical,jesup https://reviewboard.mozilla.org/r/45465/#review43161
Updated•8 years ago
|
Attachment #8741342 -
Flags: review?(rjesup) → review+
Comment 10•8 years ago
|
||
Comment on attachment 8741342 [details] MozReview Request: Bug 1206708 - Allow YUV images with gaps between planes in MediaPipelineTransmit. r?jesup https://reviewboard.mozilla.org/r/46399/#review43159 r+ if we can add a debug/assertion back (unless there's a good reason not to) ::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:366 (Diff revision 1) > + MOZ_MTLOG(ML_DEBUG, "Sending an I420 video frame"); > + VideoFrameConverted(i420_frame); > + return; > } It appears we lost any sort of debug/assertion on not getting ycrcb data....
Assignee | ||
Comment 11•8 years ago
|
||
https://reviewboard.mozilla.org/r/46399/#review43159 > It appears we lost any sort of debug/assertion on not getting ycrcb data.... The old check was for contiguous planes, but the modified code can live without that. There's not really a way to fail this anymore -- so what do you want to assert?
Assignee | ||
Updated•8 years ago
|
Flags: needinfo?(rjesup)
Comment 12•8 years ago
|
||
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #11) > https://reviewboard.mozilla.org/r/46399/#review43159 > > > It appears we lost any sort of debug/assertion on not getting ycrcb data.... > > The old check was for contiguous planes, but the modified code can live > without that. There's not really a way to fail this anymore -- so what do > you want to assert? You're right; misread it - thought it was for the if (data) test. Never mind - land!
Flags: needinfo?(rjesup)
Assignee | ||
Comment 13•8 years ago
|
||
Final check: https://treeherder.mozilla.org/#/jobs?repo=try&revision=1d476e89b664
Comment 14•8 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/08f50e080cdd https://hg.mozilla.org/integration/mozilla-inbound/rev/13f36f3e3181
Comment 15•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/08f50e080cdd https://hg.mozilla.org/mozilla-central/rev/13f36f3e3181
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in
before you can comment on or make changes to this bug.
Description
•