The small-shot.m4a duration is assigned |MediaDecoderStateMachine::OnMetadataRead|, then send metadataload event to main thread. I suspect there is a racing between "set mDuration" and "MediaDecoderStateMachine::EnqueueLoadedMetadataEvent". 1. The "set mDuration" is a Canonical, so it will dispatch a task(DoNotify) to self then dispatch to main thread. 2. "MediaDecoderStateMachine::EnqueueLoadedMetadataEvent" seems dispatch to main thread directly. So the "metadataload event" is before than "mirror value update" in main thread. Once the "metadataload event" comes first, the HtmlMediaElement fires the async event "loadedmetadata" to js get the NaN duration. JW, how do you think?
https://hg.mozilla.org/mozilla-central/file/f59d1f7941b0b7358d6fa28179d60280ac2844b9/dom/media/MediaDecoder.cpp#l745 AbstractThread::MainThread() is assigned as the target thread when MediaDecoder registers a listener with the event source. Tail dispatching should kick when the event is published and sent to the listener. You can run a debugger to make sure tail dispatching is activated.
(In reply to JW Wang [:jwwang] from comment #2) > https://hg.mozilla.org/mozilla-central/file/ > f59d1f7941b0b7358d6fa28179d60280ac2844b9/dom/media/MediaDecoder.cpp#l745 > > AbstractThread::MainThread() is assigned as the target thread when > MediaDecoder registers a listener with the event source. Tail dispatching > should kick when the event is published and sent to the listener. > > You can run a debugger to make sure tail dispatching is activated. https://dxr.mozilla.org/mozilla-central/source/xpcom/threads/StateMirroring.h#195 My point is that since the set function in canonical doesn't dispatch task to mainthread(mirror) directly. So the loadedmetadata event will run before updateValue? If so, may cause the problem.
Direct tasks should run before tail dispatching.
Mass change P2 -> P3
Priority: P2 → P3
You need to log in before you can comment on or make changes to this bug.