Open Bug 1846546 Opened 2 years ago Updated 1 year ago

Only use low-latency mode in decoders when it's useful to do so

Categories

(Core :: Audio/Video: Playback, defect)

defect

Tracking

()

REOPENED

People

(Reporter: padenot, Assigned: padenot)

References

Details

(Keywords: perf-alert)

Attachments

(2 files)

From bug 1520894:

this is something we should do. This will fix the issue for non-live Youtube and others, but there is still a bug here, that we should fix.

It's only useful to use low latency decoder when playing a live source. This can save a lot of resources, and it can be more resilient against load (depending on the situation).

I'm still kinda worry about enabling low latency only when media is live, especially consider now we don't have any flag in the API to force media element using low latency. In bug 1520894, it's about the low latency didn't work well on web gaming, which is not live video so might have non-infinite duration. If we only turn the low latency on when the duration is not set, then all similar websites using low latency for other purposes might have worse performance. But having non-live video with low latency would cause higher CPU/GPU usage is also not something we want. So maybe we can use a pref to control this feature? In case that in some situation we still want to use low latency on non-live video?

By checking Chromium's code, even if they set live flag, but I can't see that flag would directly affect [1] whether using CODECAPI_AVLowLatencyMode or not. In addition, based on [2], CODECAPI_AVLowLatencyMode seems only affecting hardware decoding even if mdsn doesn't explicitly mention that.

[1]
https://source.chromium.org/search?q=StreamLiveness::kLive&sq=&ss=chromium%2Fchromium%2Fsrc

[2]
https://github.com/w3c/media-source/issues/184#issuecomment-309054314
https://source.chromium.org/chromium/chromium/src/+/main:gpu/config/gpu_preferences.h;l=115-116?q=CODECAPI_AVLowLatencyMode&ss=chromium

(In reply to Alastor Wu [:alwu] from comment #3)

I'm still kinda worry about enabling low latency only when media is live, especially consider now we don't have any flag in the API to force media element using low latency. In bug 1520894, it's about the low latency didn't work well on web gaming, which is not live video so might have non-infinite duration.

Web Gaming (here, streamed) very much is live video, how could it have a duration?

If we only turn the low latency on when the duration is not set, then all similar websites using low latency for other purposes might have worse performance. But having non-live video with low latency would cause higher CPU/GPU usage is also not something we want. So maybe we can use a pref to control this feature? In case that in some situation we still want to use low latency on non-live video?

In the absence of a dedicated API to select low-latency decoder, we don't have a choice, so we do a guess based on the container.

By checking Chromium's code, even if they set live flag, but I can't see that flag would directly affect [1] whether using CODECAPI_AVLowLatencyMode or not. In addition, based on [2], CODECAPI_AVLowLatencyMode seems only affecting hardware decoding even if mdsn doesn't explicitly mention that.

It changes their internal buffering, they don't set it on the decoder. We can do both.

Pushed by padenot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/559a73043ec5 Determine if an mp4 or a WebM is live, and pass that information to the decoder. r=alwu https://hg.mozilla.org/integration/autoland/rev/c4ff418eb757 Only enable low-latency video decoding mode on Windows when the media is live. r=alwu https://hg.mozilla.org/integration/autoland/rev/4dc0830ae686 apply code formatting via Lando

Backed out for causing build bustages in WebMDemuxer.cpp

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: /builds/worker/checkouts/gecko/dom/media/webm/WebMDemuxer.cpp:392:24: error: no member named 'media_low_latency_decoding_force_enabled' in namespace 'mozilla::StaticPrefs'
Flags: needinfo?(padenot)
Pushed by padenot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dc904b668c03 Determine if an mp4 or a WebM is live, and pass that information to the decoder. r=alwu https://hg.mozilla.org/integration/autoland/rev/a546ce2c8996 Only enable low-latency video decoding mode on Windows when the media is live. r=alwu
Pushed by padenot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0ca91e7b51ff Determine if an mp4 or a WebM is live, and pass that information to the decoder. r=alwu https://hg.mozilla.org/integration/autoland/rev/aac1f1d71d52 Only enable low-latency video decoding mode on Windows when the media is live. r=alwu
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
Flags: needinfo?(padenot)
Regressions: 1849396
Regressions: 1849438

Backed out for causing Bug 1849396

Flags: needinfo?(padenot)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 118 Branch → ---

(In reply to Pulsebot from comment #7)

Pushed by padenot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/dc904b668c03
Determine if an mp4 or a WebM is live, and pass that information to the
decoder. r=alwu
https://hg.mozilla.org/integration/autoland/rev/a546ce2c8996
Only enable low-latency video decoding mode on Windows when the media is
live. r=alwu

== Change summary for alert #39355 (as of Sat, 19 Aug 2023 14:32:24 GMT) ==

Improvements:

Ratio Test Platform Options Absolute values (old vs new)
17% basic_compositor_video windows10-64-qr e10s fission stylo webrender-sw 3.35 -> 2.79
17% basic_compositor_video windows10-64-shippable-qr e10s fission stylo webrender 3.35 -> 2.79
17% basic_compositor_video windows10-64-shippable-qr e10s fission stylo webrender-sw 3.35 -> 2.79

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

(In reply to Pulsebot from comment #9)

Pushed by padenot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0ca91e7b51ff
Determine if an mp4 or a WebM is live, and pass that information to the
decoder. r=alwu
https://hg.mozilla.org/integration/autoland/rev/aac1f1d71d52
Only enable low-latency video decoding mode on Windows when the media is
live. r=alwu

== Change summary for alert #39357 (as of Mon, 21 Aug 2023 04:41:28 GMT) ==

Improvements:

Ratio Test Platform Options Absolute values (old vs new)
18% basic_compositor_video windows10-64-qr e10s fission stylo webrender-sw 3.35 -> 2.74
18% basic_compositor_video windows10-64-shippable-qr e10s fission stylo webrender 3.34 -> 2.74

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

(In reply to Cristian Tuns from comment #11)

Backed out for causing Bug 1849396

== Change summary for alert #39371 (as of Wed, 23 Aug 2023 09:37:13 GMT) ==

Regressions:

Ratio Test Platform Options Absolute values (old vs new)
22% basic_compositor_video windows10-64-qr e10s fission stylo webrender-sw 2.74 -> 3.36
22% basic_compositor_video windows10-64-shippable-qr e10s fission stylo webrender 2.74 -> 3.34
20% basic_compositor_video windows10-64-shippable-qr e10s fission stylo webrender-sw 2.79 -> 3.34

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

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:padenot, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit BugBot documentation.

Flags: needinfo?(padenot)
Flags: needinfo?(alwu)

Yes, we still need more changes for patches in order to figure out the solution for breaking H264 playback.

Flags: needinfo?(padenot)
Flags: needinfo?(alwu)
Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: