Open Bug 1654105 Opened 4 years ago Updated 4 years ago

flac file sometimes fails to load due to NS_ERROR_DOM_MEDIA_DEMUXER_ERR ("Init() failure: waiting for data") when MIME sniffing is used

Categories

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

defect

Tracking

()

People

(Reporter: robwu, Unassigned)

References

Details

I was trying to reduce bug 1650640 (trying to load a flac file from a moz-extension:-URL in Firefox 78.0.1 on Linux), and found a different bug instead.

STR:

  1. Temporarily forgetting about the .flac MIME-association on my system:
<!--
Save as mime.xml and run:
  xdg-mime install mime.xml --novendor
When done, undo the changes:
  xdg-mime uninstall mime.xml
-->
<?xml version="1.0"?>
 <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="audio/flac">
   <glob-deleteall/>
   <magic-deleteall/>
  </mime-type>
</mime-info>
  1. Load the extension from bug 1650640 with MOZ_LOG=MediaDemuxer:5,MediaDecoder:5 web-ext run --verbose.

Expected:

  • The audio can always be played.

Actual:

  • Sometimes the audio cannot be played, but sometimes it can. When I reload the page, the playback is successful.

When I undo the MIME override (i.e. flac is a known MIME again), the expected behavior happens. Based on this observation, I conclude that the bug is related to MIME sniffing.

Good (expected):

[Child 10458: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7fb8fa49c000] state=DECODING_METADATA Dispatching AsyncReadMetadata
[Child 10458: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7fb8fa49c000] Decoder=7fb9018a5400 SetVideoDecodeModeInternal(), VideoDecodeMode=(Normal->Normal), mVideoDecodeSuspended=F
[Child 10458: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7fb8fa49c000] Decoder=7fb9018a5400 SetVideoDecodeModeInternal(), early return because the mode does not change
[Child 10458: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7fb8fa49c000] Decoder=7fb9018a5400 SetVideoDecodeModeInternal(), VideoDecodeMode=(Normal->Normal), mVideoDecodeSuspended=F
[Child 10458: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7fb8fa49c000] Decoder=7fb9018a5400 SetVideoDecodeModeInternal(), early return because the mode does not change
[Child 10458: MediaPDecoder #1]: D/MediaDemuxer FlacTrackDemuxer[0x7fb8fa415d60] Reset()
[Child 10458: MediaPDecoder #1]: D/MediaDemuxer FlacDemuxer[0x7fb8fa433b60] Init() successful

Bad:

[Child 10741: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7f6cfb199000] state=DECODING_METADATA Dispatching AsyncReadMetadata
[Child 10741: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7f6cfb199000] Decoder=7f6d0249bc00 SetVideoDecodeModeInternal(), VideoDecodeMode=(Normal->Normal), mVideoDecodeSuspended=F
[Child 10741: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7f6cfb199000] Decoder=7f6d0249bc00 SetVideoDecodeModeInternal(), early return because the mode does not change
[Child 10741: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7f6cfb199000] Decoder=7f6d0249bc00 SetVideoDecodeModeInternal(), VideoDecodeMode=(Normal->Normal), mVideoDecodeSuspended=F
[Child 10741: MediaDecoderStateMachine #1]: D/MediaDecoder MediaDecoderStateMachine[0x7f6cfb199000] Decoder=7f6d0249bc00 SetVideoDecodeModeInternal(), early return because the mode does not change
[Child 10741: MediaPDecoder #1]: D/MediaDemuxer FlacTrackDemuxer[0x7f6cfb1207b0] Reset()
[Child 10741: MediaPDecoder #1]: D/MediaDemuxer FlacDemuxer[0x7f6cfb13d640] Init() failure: waiting for data
[Child 10741, MediaDecoderStateMachine #1] WARNING: Decoder=7f6d0249bc00 state=DECODING_METADATA Decode metadata failed, shutting down decoder: file /build/firefox/src/firefox-78.0.1/dom/media/MediaDecoderStateMachine.cpp, line 376
[Child 10741, MediaDecoderStateMachine #1] WARNING: Decoder=7f6d0249bc00 Decode error: NS_ERROR_DOM_MEDIA_DEMUXER_ERR (0x806e000c): file /build/firefox/src/firefox-78.0.1/dom/media/MediaDecoderStateMachine.cpp, line 3470

JS console in index.html:

Media resource moz-extension://d2815a85-7b64-4610-b02d-908e04b1a611/pop.flac could not be decoded.
Media resource moz-extension://d2815a85-7b64-4610-b02d-908e04b1a611/pop.flac could not be decoded, error: Error Code: NS_ERROR_DOM_MEDIA_DEMUXER_ERR (0x806e000c)

Based on the log output, this code path appears to be triggered: https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/media/flac/FlacDemuxer.cpp#565-569

Since the flac file content is really available, I guess that the initialization logic incorrectly fails to wait for enough bytes to be available.

Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.