vtdec: seeks freeze the pipeline
Describe your issue
On old-ish Intel Mac's any Mac, both ARM and Intel ones, when using the vtdec decoder (hardware and software) the pipeline freezes when emitting a seek event.
It's easier to reproduce on Intel Mac where it's reproducible after 1 or 2 seeks. On ARM ones, it's also reproducible but it requires more seeks to reproduce the race.
This is a regression that I can reproduce starting from 1.24.1 and that's working correctly in 1.22.12.
Expected Behavior
Seeks works correctly without freezing the pipeline
Observed Behavior
Analyzing the logs, it seems caused by vtdec
not resetting correctly the internal flushing flag after FLUSH_STOP
and stopping the decoding loop when decoding the first frame after flush finished.
0:00:14.866473509 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:798:gst_vtdec_sink_event:<vtdec0> flush stop received, removing flushing flag
0:00:14.866618197 1119 0x7fea460358c0 DEBUG vtdec vtdec.c:861:gst_vtdec_handle_frame:<vtdec0> Output loop stopped because of flushing, ignoring frame
Output log reproducing the issue where the first seek succeeds and the second one doesn't.
GST_DEBUG=*vtdec*:5 ./gst-launch-1.0 filesrc location=Borussia-Bayern-002.mp4 ! qtdemux ! vtdec ! videoconvert ! navseek ! osxvideosink
Setting pipeline to PAUSED ...
0:00:00.212608420 1119 0x7fea46809de0 DEBUG vtdec vtdec.c:230:gst_vtdec_start:<vtdec0> start
Pipeline is PREROLLING ...
0:00:00.231340541 1119 0x7fea460358c0 DEBUG vtdec vtdec.c:694:gst_vtdec_set_format:<vtdec0> set_format
0:00:00.231702343 1119 0x7fea460358c0 INFO vtdec vtdec.c:1512:compute_h264_decode_picture_buffer_size:<vtdec0> parsed profile 77, level 31
0:00:00.231751390 1119 0x7fea460358c0 DEBUG vtdec vtdec.c:1415:gst_vtdec_compute_dpb_size:<vtdec0> Calculated DPB size: 2
0:00:00.231788933 1119 0x7fea460358c0 INFO vtdec vtdec.c:1580:gst_vtdec_set_latency:<vtdec0> setting latency frames:2 time:0:00:00.080000000
Redistribute latency...
0:00:00.232812516 1119 0x7fea460358c0 INFO vtdec vtdec.c:578:gst_vtdec_negotiate:<vtdec0> negotiated output format video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1 previous (NULL)
0:00:00.444624639 1119 0x7fea460358c0 INFO vtdec vtdec.c:585:gst_vtdec_negotiate:<vtdec0> using hardware decoder
0:00:00.452439598 1119 0x7fea460358c0 DEBUG vtdec vtdec.c:1301:gst_vtdec_drain_decoder:<vtdec0> drain_decoder, flushing: 0
0:00:00.452494326 1119 0x7fea460358c0 DEBUG vtdec vtdec.c:404:gst_vtdec_pause_output_loop:<vtdec0> paused output thread
0:00:00.452512543 1119 0x7fea460358c0 DEBUG vtdec vtdec.c:1346:gst_vtdec_drain_decoder:<vtdec0> buffer queue cleaned
0:00:00.453091166 1119 0x7fea460358c0 INFO vtdec vtdec.c:511:gst_vtdec_negotiate:<vtdec0> current and peer caps are compatible, keeping current caps
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstSystemClock
0:00:10.052664438 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:779:gst_vtdec_sink_event:<vtdec0> flush start received, setting flushing flag
0:00:10.053085676 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:754:gst_vtdec_flush:<vtdec0> flush
0:00:10.053105998 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:1301:gst_vtdec_drain_decoder:<vtdec0> drain_decoder, flushing: 1
0:00:10.053143592 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:404:gst_vtdec_pause_output_loop:<vtdec0> paused output thread
0:00:10.053156726 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:1346:gst_vtdec_drain_decoder:<vtdec0> buffer queue cleaned
0:00:10.053218970 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:798:gst_vtdec_sink_event:<vtdec0> flush stop received, removing flushing flag
Redistribute latency...
0:00:14.866040000 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:779:gst_vtdec_sink_event:<vtdec0> flush start received, setting flushing flag
0:00:14.866372033 1119 0x7fea46035860 DEBUG vtdec vtdec.c:381:gst_vtdec_output_loop:<vtdec0> pausing output task: flushing
0:00:14.866396661 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:754:gst_vtdec_flush:<vtdec0> flush
0:00:14.866417795 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:1301:gst_vtdec_drain_decoder:<vtdec0> drain_decoder, flushing: 1
0:00:14.866434587 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:404:gst_vtdec_pause_output_loop:<vtdec0> paused output thread
0:00:14.866443335 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:1350:gst_vtdec_drain_decoder:<vtdec0> buffer queue not cleaned, output thread returned flushing
0:00:14.866473509 1119 0x7fea4825b150 DEBUG vtdec vtdec.c:798:gst_vtdec_sink_event:<vtdec0> flush stop received, removing flushing flag
0:00:14.866618197 1119 0x7fea460358c0 DEBUG vtdec vtdec.c:861:gst_vtdec_handle_frame:<vtdec0> Output loop stopped because of flushing, ignoring frame
Setup
- Operating System: maOS
- Device: Computer
- GStreamer Version: 1.24.11
- Command line: ./gst-launch-1.0 filesrc location=Borussia-Bayern-002.mp4 ! qtdemux ! vtdec ! videoconvert ! navseek ! osxvideosink
Steps to reproduce the bug
- Run ./gst-launch-1.0 filesrc location=Borussia-Bayern-002.mp4 ! qtdemux ! vtdec ! videoconvert ! navseek ! osxvideosink
- Use the arrow keys to emit seeks
- The pipeline will freeze after a seek is emitted.
How reproducible is the bug?
This bug is very easily reproducible, around 90% of the seeks fail.
Screenshots if relevant
Solutions you have tried
Using a different decoder seeks work correctly.