Closed Bug 1695265 Opened 4 years ago Closed 4 years ago

Implement a new type of media stream track used in `DecodedStream` to support pull-based system

Categories

(Core :: Audio/Video: MediaStreamGraph, task)

task

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: alwu, Assigned: alwu)

References

Details

(Keywords: perf-alert)

Attachments

(3 files, 3 obsolete files)

This is pre-requirement before implementing time stretching in bug 1517199.

Following paragraphs are copied from :padenot.

HTMLMediaElement can output to a MediaStream. For now it uses DecodedStream, which is push-based. Every time it wants to write, it pushes all of its decoded audio queue to the MTG. The MTG then pulls this data little by little.

If we do the time stretching when pushing, there will be a high latency between playbackRate changes and the playback rate actually changing. This, but for volume changes, has been the source of vocal complaints in the past.

It’s also the last source of the MTG that is push based. Moving it to be pull-based would be nice, this fits in well with our future plans of removing AudioStream and associated machinery.

There is however quite a few bits before we can do the (now easy) task of inserting a time stretcher as a graph input.

Quick update: Currently my patches work well, but got a wpt failure. I'm still debugging that.

Hi, Alastor Wu,
I am looking for a solution for PlaybackRate when html element(audio or video) is connected to createMediaElementSource. Thanks for any suggestion in advance.

(In reply to fahadsharifjutt from comment #2)

Hi, Alastor Wu,
I am looking for a solution for PlaybackRate when html element(audio or video) is connected to createMediaElementSource. Thanks for any suggestion in advance.

That is the purpose of this bug, this bug is a pre-requirement before supporting playback change on the media stream track, which is captured from the media element.

AudioDecoderInputTrack stores the audio data in a SPSC queue which allows MTG to pull data from it by calling AudioDecoderInputTrack::AppendData().

As we will use AudioDecoderInputTrack for audio track later, need to remove some dependency of SourceMediaTrack first.

Current GetElementsAfter() doesn't gurantee that, the result array would still contain the element which end time is earlier or equal to the given time.

Depends on D106041

Attachment #9206824 - Attachment is obsolete: true
Attachment #9206823 - Attachment description: Bug 1695265 - part1 : implement AudioDecoderInputTrack. → Bug 1695265 - part1 : implement AudioDecoderInputTrack. r?pehrsons
Attachment #9206825 - Attachment description: Bug 1695265 - part3 : implement a new method on media queue to return an array which endtime are all strictly later than the given time. → Bug 1695265 - part2 : implement a new method on media queue to return an array which endtime are all strictly later than the given time. r?bryce
Attachment #9206826 - Attachment description: Bug 1695265 - part4 : use `AudioDecoderInputTrack` for audio in `DecodedStream`. → Bug 1695265 - part3 : use `AudioDecoderInputTrack` for audio in `DecodedStream`. r?pehrsons

Comment on attachment 9206825 [details]
Bug 1695265 - part2 : implement a new method on media queue to return an array which endtime are all strictly later than the given time. r?bryce

Revision D107170 was moved to bug 1701992. Setting attachment 9206825 [details] to obsolete.

Attachment #9206825 - Attachment is obsolete: true
Attachment #9206826 - Attachment description: Bug 1695265 - part3 : use `AudioDecoderInputTrack` for audio in `DecodedStream`. r?pehrsons → Bug 1695265 - part2 : use `AudioDecoderInputTrack` for audio in `DecodedStream`. r?pehrsons

Because the media event source cleans its listener lazily, that only happens when the source dispatches another new event. If the source didn't dispatch any new event after the listeners revoke themself, then they would be always kept in the media event source as a strong reference.

That doesn't matter in other current usage, but it would cause a memory leak in our case.

  • A <-- B : B holds a strong reference to A

DecodedStreamGraphListener <-- lambda as a media event callback <-- ListenerImpl <-- MediaEventSource (mOnEnd/mOnOutput) <-- AudioDecoderInputTrack <-- DecodedStreamGraphListener

So it causes a loop and then all those objects would be leaked. Therefore, we have to break the reference manually when the AudioDecoderInputTrack::DestroyImpl() gets called.

Depends on D106042

Depends on: 1702363
Attachment #9212986 - Attachment description: Bug 1695265 - part4 : add gtest for 'AudioDecoderInputTrack'. → WIP: Bug 1695265 - part4 : add gtest for 'AudioDecoderInputTrack'.
Attachment #9212610 - Attachment is obsolete: true
Depends on: 1702823
Attachment #9212986 - Attachment description: WIP: Bug 1695265 - part4 : add gtest for 'AudioDecoderInputTrack'. → Bug 1695265 - part3 : add gtest for 'AudioDecoderInputTrack'. r?pehrsons
Attachment #9206823 - Attachment description: Bug 1695265 - part1 : implement AudioDecoderInputTrack. r?pehrsons → Bug 1695265 - part1 : implement AudioDecoderInputTrack.
Attachment #9212986 - Attachment description: Bug 1695265 - part3 : add gtest for 'AudioDecoderInputTrack'. r?pehrsons → Bug 1695265 - part3 : add gtest for 'AudioDecoderInputTrack'.
Pushed by alwu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/52861f76787f part1 : implement AudioDecoderInputTrack. r=pehrsons https://hg.mozilla.org/integration/autoland/rev/35cb5f5e17b7 part2 : use `AudioDecoderInputTrack` for audio in `DecodedStream`. r=pehrsons https://hg.mozilla.org/integration/autoland/rev/7d2f645a1dc4 part3 : add gtest for 'AudioDecoderInputTrack'. r=pehrsons,padenot
Attachment #9206826 - Attachment description: Bug 1695265 - part2 : use `AudioDecoderInputTrack` for audio in `DecodedStream`. r?pehrsons → Bug 1695265 - part2 : use `AudioDecoderInputTrack` for audio in `DecodedStream`.
Flags: needinfo?(alwu)
Pushed by alwu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5ac05c27c39b part1 : implement AudioDecoderInputTrack. r=pehrsons https://hg.mozilla.org/integration/autoland/rev/3ee41652c232 part2 : use `AudioDecoderInputTrack` for audio in `DecodedStream`. r=pehrsons https://hg.mozilla.org/integration/autoland/rev/43c02933d6bc part3 : add gtest for 'AudioDecoderInputTrack'. r=pehrsons,padenot
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
Regressions: 1708433
Regressions: 1708454
Regressions: 1709130
Blocks: 1709899

== Change summary for alert #30032 (as of Mon, 10 May 2021 04:54:26 GMT) ==

Improvements:

Ratio Suite Test Platform Options Absolute values (old vs new)
5% perf_reftest_singletons (docs) getElementById-1.html windows10-64-shippable e10s stylo 50.28 -> 47.64

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=30032

Regressions: 1712595
Blocks: 1712598
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: