Closed Bug 1643855 Opened 4 years ago Closed 4 years ago

[Wayland] Hardware accelerated video playback interrupted - wrong surface release

Categories

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

79 Branch
x86_64
Linux
defect

Tracking

()

RESOLVED DUPLICATE of bug 1656436
Tracking Status
firefox79 --- disabled

People

(Reporter: jhnmlkvch9, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0

Steps to reproduce:

I'm Using Intel i915 driver with hardware acceleration and playing h264 video.

  1. Play a youtube video with h264 (using enhanced-h264ify)
  2. Open any other program that uses intel hardware acceleration (like another ff instance)
  3. The video that is playing stops and an error is displayed in the youtube window.

Actual results:

Video stops.

Here is the console output when log is enabled:

[Child 30962, MediaDecoderStateMachine #1] WARNING: Decoder=7fdcf6ab3400 Decode error: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004) - virtual mozilla::MediaResult mozilla::FFmpegVideoDecoder<58>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, MediaDataDecoder::DecodedData &): avcodec_send_packet error: -1094995529: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470
[Child 30962, MediaDecoderStateMachine #1] WARNING: Decoder=7fdcf6ab3400 Decode error: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004) - virtual mozilla::MediaResult mozilla::FFmpegVideoDecoder<58>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, MediaDataDecoder::DecodedData &): avcodec_send_packet error: -1094995529: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470
[Child 30962, MediaDecoderStateMachine #1] WARNING: Decoder=7fdcf6ab3400 Decode error: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004) - virtual mozilla::MediaResult mozilla::FFmpegVideoDecoder<58>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, MediaDataDecoder::DecodedData &): avcodec_send_packet error: -1094995529: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470
[Child 30962, MediaDecoderStateMachine #1] WARNING: Decoder=7fdcf6ab3400 Decode error: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004) - virtual mozilla::MediaResult mozilla::FFmpegVideoDecoder<58>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, MediaDataDecoder::DecodedData &): avcodec_send_packet error: -1094995529: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470
[Child 30962, MediaDecoderStateMachine #1] WARNING: Decoder=7fdcf6ab3400 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - RefPtr<MediaSourceTrackDemuxer::SamplesPromise> mozilla::MediaSourceTrackDemuxer::DoGetSamples(int32_t): manager is detached.: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470
[Child 30962, MediaDecoderStateMachine #1] WARNING: Decoder=7fdcf6ab3400 Decode error: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004) - virtual mozilla::MediaResult mozilla::FFmpegVideoDecoder<58>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, MediaDataDecoder::DecodedData &): avcodec_send_packet error: -1094995529: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470

Expected results:

Video should continue playing.

I'm using latest ff nightly on swaywm.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

Is that the only error message you see? Do you have anything in your logs? Please run "dmesg" an "journal -b" on terminal.
I don't see such error on UHD Graphics 630 / Fedora 32 / Gnome so can you try Gnome for instance?
Thanks.

Component: Widget: Gtk → Audio/Video: Playback
Flags: needinfo?(jhnmlkvch9)
Priority: -- → P3

Sway Wayland, Debian Testing, Macbook Pro (0x8086 0x162b, Intel Iris Graphics 6100 (BDW GT3))

I ran two instances of Nightly, first two of 2020-06-10, then two of 2020-06-05 and unfortunately could not reproduce a problem. Both videos play and I see "Got one VAAPI frame output" getting spammed in both terminals.

$ pip3 install --upgrade mozregression
$ MOZ_LOG="PlatformDecoderModule:5" LIBVA_DRIVER_NAME=i965 MOZ_ENABLE_WAYLAND=1 mozregression --launch 2020-06-10 --pref gfx.webrender.all:true widget.wayland-dmabuf-vaapi.enabled:true -a https://bug1619882.bmoattachments.org/attachment.cgi?id=9149605 -a https://addons.mozilla.org/en-US/firefox/addon/enhanced-h264ify/ -a https://www.youtube.com/watch?v=LXb3EKWsInQ -P stdout

Unfortunately, I don't see anything in dmesg. I did manage to get a crash though, during one of the video pause events. I'm including the details of the log generated. Not sure if it will be helpful.

Flags: needinfo?(jhnmlkvch9)
Attached file crash log (deleted) —

I have a multi gpu setup with intel integrated and discrete nvidia with external monitors connected. Not sure if it is relevant, but thought I'd mention that.

This is what I see in the WM log:

[Child 35967, MediaDecoderStateMachine #1] WARNING: Decoder=7fa30a73d400 Decode error: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004) - virtual mozilla::MediaResult mozilla::FFmpegVideoDecoder<58>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, MediaDataDecoder::DecodedData &): avcodec_send_packet error: -1094995529: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470
[Child 35967, MediaDecoderStateMachine #1] WARNING: Decoder=7fa30a73d400 Decode error: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004) - virtual mozilla::MediaResult mozilla::FFmpegVideoDecoder<58>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, MediaDataDecoder::DecodedData &): avcodec_send_packet error: -1094995529: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470
[Child 35967, MediaDecoderStateMachine #1] WARNING: Decoder=7fa30a73d400 Decode error: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004) - virtual mozilla::MediaResult mozilla::FFmpegVideoDecoder<58>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, MediaDataDecoder::DecodedData &): avcodec_send_packet error: -1094995529: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470
[Child 35967, MediaDecoderStateMachine #1] WARNING: Decoder=7fa30a73d400 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - RefPtr<MediaSourceTrackDemuxer::SamplesPromise> mozilla::MediaSourceTrackDemuxer::DoGetSamples(int32_t): manager is detached.: file /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3470

Attached is the full log of triggering this issue with youtube on nightly build 20200615092624.
This is on Debian unstable with gnome-shell/mutter version 3.36.3.

journalctl does not show anything relevant, it just echoes the IPDL/decode error warnings in the attached full log. Nothing on the kernel log either.

I keep seeing a typical video-glitch-green flash on youtube, which seems to be related to the chunks of the stream. vlc works fine with the same video.

vainfo:

libva info: VA-API version 1.7.0
libva info: User environment variable requested driver 'i965'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_5
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.7.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell - 2.4.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      :	VAEntrypointVLD
      VAProfileH264MultiviewHigh      :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileH264StereoHigh         :	VAEntrypointEncSlice
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileJPEGBaseline           :	VAEntrypointVLD
Attached file corrupt.txt (deleted) —

Gnome Wayland, Debian Testing, Macbook Pro, Mesa 20.0.7, Intel Iris Graphics 6100 (BDW GT3)

As of bug 1629788 I'm able to reproduce this. With the commit before, I'm not able to. After a few seconds, playback stops with "Video can't be played because the file is corrupt".

MOZ_LOG="PlatformDecoderModule:5" LIBVA_DRIVER_NAME=i965 MOZ_ENABLE_WAYLAND=1 mozregression --repo autoland --launch 0c7df6f9b0c1999f37b231705f85e44df689bab0 --pref gfx.webrender.all:true widget.wayland-dmabuf-vaapi.enabled:true widget.wayland-dmabuf-video-textures.enabled:true media.ffvpx.enabled:false -a file:///home/darkspirit/Videos/LG%20Landscape%204K%20Demo.mp4 -P stdout > corrupt.txt

I don't see this problem when playing a lightweight video like https://bug1619882.bmoattachments.org/attachment.cgi?id=9149605.

There's related part of the log:
[h264 @ 0x7f383bd20800] get_buffer() failed
[h264 @ 0x7f383bd20800] thread_get_buffer() failed
[h264 @ 0x7f383bd20800] decode_slice_header error
[h264 @ 0x7f383bd20800] no frame!

looks like hw decoder error.

(In reply to Jan Andre Ikenmeyer [:darkspirit] from comment #9)
Ctrl+F "Surface UID = 5" and search from the bottom up. It is double released and double reused.

[...]
0:28.12 INFO: b'[Child 32476: MediaPDecoder #2]: D/PlatformDecoderModule DMABufSurface: VAAPI releasing dmabuf surface UID = 5'
[...]
0:28.14 INFO: b'[Child 32476: MediaPDecoder #2]: D/PlatformDecoderModule DMABufSurface: VAAPI releasing dmabuf surface UID = 5'
[...]
0:28.15 INFO: b'[Child 32476: MediaPDecoder #2]: D/PlatformDecoderModule Reusing WaylandDMABufSurface UID = 5'
0:28.15 INFO: b'[Child 32476: MediaPDecoder #2]: D/PlatformDecoderModule DMABufSurface: VAAPI locking dmabuf surface UID = 5'
[...]
0:28.35 INFO: b'[Child 32476: MediaPDecoder #3]: D/PlatformDecoderModule Reusing WaylandDMABufSurface UID = 5'
0:28.35 INFO: b'[Child 32476: MediaPDecoder #3]: D/PlatformDecoderModule DMABufSurface: VAAPI locking dmabuf surface UID = 5'
[...]
0:28.56 INFO: b'[Child 32476: MediaPDecoder #3]: D/PlatformDecoderModule Reusing WaylandDMABufSurface UID = 5'
0:28.56 INFO: b'[Child 32476: MediaPDecoder #3]: D/PlatformDecoderModule DMABufSurface: VAAPI locking dmabuf surface UID = 5'
0:28.56 INFO: b'[Child 32476: MediaPDecoder #3]: D/PlatformDecoderModule DMABufSurface: VAAPI releasing dmabuf surface UID = 7'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] nal_unit_type: 6(SEI), nal_ref_idc: 0'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] NALFF: Consumed only 204348 bytes instead of 521322'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] nal_unit_type: 12(Filler data), nal_ref_idc: 0'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] ct_type:1 pic_struct:0'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] get_buffer() failed'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] thread_get_buffer() failed'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] decode_slice_header error'
0:28.57 INFO: b'[h264 @ 0x7fdd5e5cc000] no frame!'

(In reply to Jan Andre Ikenmeyer [:darkspirit] from comment #13)
from my log:
UID 5 is released twice by MediaPDecoder #2 before being reused by MediaPDecoder #2.
MediaPDecoder #3 is reusing UID 5 twice without releasing it in between.

(In reply to Martin Stránský [:stransky] from comment #12)
log from comment 8:
UID 19 was released at least 15 times before being reused. Is that intended?
MediaPDecoder #2 releases UID 19 at least 8 times (without reusing),
MediaPDecoder #3 releases UID 19 at least 6 times (without reusing),
before MediaPDecoder #1 reuses UID 19.

I'll look at it when Bug 1645704 lands.
Thanks.

Summary: [Wayland] Hardware accelerated video playback interrupted → [Wayland] Hardware accelerated video playback interrupted - wrong surface release
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → Linux
Hardware: Unspecified → x86_64

Could bug 1376999 be relevant? (Is it obsolete?)

A couple of things:

  1. The crashes come in thick and fast if you increase the playback speed (say to 2x). I also think there is some relation here to the video resolution, but I haven't been able to pin it down.
  2. When running FF using Nvidia card (with nouveau drivers), all I see is a green scrambled window where video is supposed to be playing. Audio works fine.

I'm not sure if HW accel is even supposed to work with nouveau, but if there is a reasonable expectation of it, let me know and I can report a separate bug for 2.

Bug 1645672 and this have been fixed in Nightly 81.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: