Closed Bug 1890500 Opened 2 years ago Closed 2 years ago

[wpt-sync] Sync PR 45623 - Implement MediaStreamTrackAudioStats

Categories

(Testing :: web-platform-tests, task, P4)

task

Tracking

(firefox127 fixed)

RESOLVED FIXED
127 Branch
Tracking Status
firefox127 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 45623 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/45623
Details from upstream follow.

Fredrik Hernqvist <fhernqvist@google.com> wrote:

Implement MediaStreamTrackAudioStats

This implements MediaStreamTrackAudioStats as specified in
https://w3c.github.io/mediacapture-extensions/#the-mediastreamtrackaudiostats-interface

To test the CL, you can go to
https://webrtc.github.io/samples/src/content/getusermedia/audio/
and evaluate audio.srcObject.getAudioTracks()[0].stats in the
console.

Review guide (please read this first):
1.
The stats are aggregated in MediaStreamAudioTrack and exposed in
MediaStreamTrackAudioStats. They travel this path:
AUDIO THREAD:
MediaStreamAudioTrack::OnData() ->
MediaStreamAudioTrack::UpdateGlitchInfo() ->
Stats are written to MediaStreamAudioTrack::pending_frame_stats_ ->
If lock is free, stats are written to
MediaStreamAudioTrack::mainthread_frame_stats_
MAIN THREAD:
The web app calls any getter in MediaStreamTrackAudioStats ->
MediaStreamTrackAudioStats::PopulateStatsCache() \<-
MediaStreamTrackImpl::GetAudioFrameStats() \<-
MediaStreamTrackPlatform::GetAudioFrameStats() \<-
MediaStreamAudioTrack::GetAudioFrameStats() (override) \<-
Takes lock and returns MediaStreamAudioTrack::mainthread_frame_stats_

Because the stats keep track of minimum and maximum latencies over
resettable intervals, copying stats is a bit complicated. We store the
frame counters as well as the min, max and integral of the latencies
for certain intervals in the AudioFrameStats object, which has certain
invariants that should be maintained when the stats are moved.
In particular, all AudioFrameStats objects stored in memory should
have non-overlapping latency interval information, which is ensured by
using the AudioFrameStats::CopyCountersAndMoveLatencyStatsTo() method
to move them around.

The latency information is stored in these places in memory and is
moved according to the arrows:

  • MediaStreamAudioTrack::pending_frame_stats_ (most recent stats,
    updated on the audio thread) ->
  • MediaStreamAudioTrack::mainthread_frame_stats_ (stats that have been
    pushed from the audio thread and can be read on the main thread) ->
  • MediaStreamTrackAudioStats::stats_ (least recent stats, these are
    updated at most once per javascript execution cycle)

An additional complication is the run-to-completion semantics in
combination with the resetLatency() method. Note that as specified
in the spec, resetLatency() should set averageLatency, minimumLatency
and maximumLatency to the last latency within the same task, and start
showing new min/max/average latencies only in the next task.
Additionally, resetLatency() should ONLY reset latency that has
already been observed in the same task (resetting also counts as
observing). We achieve this by only resetting the latency information in MediaStreamTrackAudioStats::stats_, which means the any newer latency
information that might have been accumulated during the task is left
untouched and will be exposed during the next task.

This might be a good order to read the files:

  • media_stream_track_audio_stats.idl (the javacsript interface)
  • media_stream_track_audio_stats.cc and .h (corresponding c++ code.
    You can compare this with media_stream_track_video_stats which has
    similar patterns)
  • media_stream_track.idl and .h (MediaStream js change)
  • media_stream_track_impl.h and .cc (creates the stats objects)
  • media_stream_track_platform.h and .cc (internal API for getting and
    storing stats and definition of AudioFrameStats)
  • media_stream_audio_track.* (stats aggregation)
    Then the rest of the changes in whatever order.

Bug: 40287624
Change-Id: Id2530f989d9678ff96b211278c4eb8ee7679ff5a

Reviewed-on: https://chromium-review.googlesource.com/5392803
WPT-Export-Revision: 6ba3dc0fc3636cdd6f35d5cba72a3baf2259eaa5

Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

Ran 9 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 2 tests and 15 subtests

Status Summary

Firefox

OK : 2
FAIL: 25

Chrome

OK : 2
PASS: 15
FAIL: 10

Safari

OK : 2
FAIL: 25

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

  • /mediacapture-extensions/MediaStreamTrack-audio-stats.https.html [wpt.fyi]
    • totalFrames and totalFramesDuration increase over time: FAIL (Chrome: FAIL, Safari: FAIL)
    • deliveredFrames and deliveredFramesDuration are at most as large as totalFrames and totalFramesDuration: FAIL (Chrome: FAIL, Safari: FAIL)
    • Latency and averageLatency is within the bounds of minimumLatency and maximumLatency: FAIL (Chrome: FAIL, Safari: FAIL)
    • Immediately after resetLatency(), latency, averageLatency, minimumLatency and maximumLatency are equal to the most recent latency.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Stats do not change within the same task execution cycle.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Stats are frozen while disabled: FAIL (Chrome: FAIL, Safari: FAIL)
    • SameObject policy applies: FAIL (Chrome: FAIL, Safari: FAIL)
    • Counters increase even if we don't call the track.stats getter: FAIL (Chrome: FAIL, Safari: FAIL)
    • Disabling and re-enabling does not reset the counters: FAIL (Chrome: FAIL, Safari: FAIL)
    • New stats baselines when a track is cloned from an enabled track: FAIL (Chrome: FAIL, Safari: FAIL)
  • /mediacapture-extensions/MediaStreamTrack-video-stats.https.html [wpt.fyi]
    • totalFrames increases over time: FAIL (Chrome: PASS, Safari: FAIL)
    • deliveredFrames increases, even without sinks: FAIL (Chrome: PASS, Safari: FAIL)
    • discardedFrames increases when frameRate decimation is happening: FAIL (Chrome: PASS, Safari: FAIL)
    • Counters increase even if we don't call the track.stats getter: FAIL (Chrome: PASS, Safari: FAIL)
    • Counters do not increase in the same task execution cycle: FAIL (Chrome: PASS, Safari: FAIL)
    • totalFrames is the sum of deliveredFrames and discardedFrames: FAIL (Chrome: PASS, Safari: FAIL)
    • SameObject policy applies: FAIL (Chrome: PASS, Safari: FAIL)
    • Stats are frozen while disabled: FAIL (Chrome: PASS, Safari: FAIL)
    • Disabling and re-enabling does not reset the counters: FAIL (Chrome: PASS, Safari: FAIL)
    • New stats baselines when a track is cloned from a disabled track: FAIL (Chrome: PASS, Safari: FAIL)
    • New stats baselines when a track is cloned from an enabled track: FAIL (Chrome: PASS, Safari: FAIL)
    • New stats baselines for the clone of a clone: FAIL (Chrome: PASS, Safari: FAIL)
    • A low FPS clone does not affect the original track's discardedFrames: FAIL (Chrome: PASS, Safari: FAIL)
    • track.stats is null on non-device tracks, such as canvas: FAIL (Chrome: PASS, Safari: FAIL)
    • track.stats is supported on getDisplayMedia tracks: FAIL (Chrome: PASS, Safari: FAIL)
Pushed by wptsync@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/64a97d67e721 [wpt PR 45623] - Implement MediaStreamTrackAudioStats, a=testonly https://hg.mozilla.org/integration/autoland/rev/0ff946c4347e [wpt PR 45623] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 127 Branch
You need to log in before you can comment on or make changes to this bug.