Bug 173387 - loadedmetadata event triggers before we can report the number of audio and video tracks
Summary: loadedmetadata event triggers before we can report the number of audio and vi...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-06-14 16:11 PDT by Antoine Quint
Modified: 2018-07-02 16:15 PDT (History)
5 users (show)

See Also:


Attachments
Testcase (920 bytes, text/html)
2017-06-14 16:11 PDT, Antoine Quint
no flags Details
media file used by test (188.32 KB, video/mp4)
2017-06-14 16:11 PDT, Antoine Quint
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Quint 2017-06-14 16:11:17 PDT
Created attachment 312926 [details]
Testcase

When a video is loaded, we dispatch the "resize" and "loadedmetadata" events first, but when either is dispatched, at least with a local file, audioTracks and videoTracks are empty. We get "addtracks" events for both of those properties later on, at which point we correctly get the list of tracks. This means that catching a "loadedmetadata" is not sufficient to obtain basic information about the media. In STP 33, the attached test reports the following:

Received "resize" on [object HTMLVideoElement]
    time since last event – "8.50ms"
    videoWidth – 320
    videoHeight – 240
    audioTracks – 0
    videoTracks – 0

Received "loadedmetadata" on [object HTMLVideoElement]
    time since last event – "1.30ms"
    videoWidth – 320
    videoHeight – 240
    audioTracks – 0
    videoTracks – 0

Received "addtrack" on [object AudioTrackList]
    time since last event – "6.60ms"
    videoWidth – 320
    videoHeight – 240
    audioTracks – 1
    videoTracks – 1

Received "addtrack" on [object VideoTrackList]
    time since last event – "0.40ms"
    videoWidth – 320
    videoHeight – 240
    audioTracks – 1
    videoTracks – 1
Comment 1 Antoine Quint 2017-06-14 16:11:34 PDT
Created attachment 312927 [details]
media file used by test
Comment 2 Radar WebKit Bug Importer 2017-06-14 16:11:58 PDT
<rdar://problem/32778557>
Comment 3 Antoine Quint 2017-06-14 16:14:29 PDT
I don't think it makes sense that we report non-zero videoWidth/videoHeight values when videoTracks.length is 0. I would expect that we only dispatch "addtrack" and other track event in the event that the track list changes *after* the "loadedmetadata" event is fired and that when dispatching "loadedmetadata" we ought to have the initial list of tracks reflected.
Comment 4 Oren Me 2018-06-27 06:33:12 PDT
Is there a fix for this? what is the expected behaviour?
When using hls.js or shaka(MSE based playback libs) the metadata is already available before loadeddata is dispatched.