Bug 258200 - [GStreamer][DMABuf] AV1 video is broken with the dav1d decoder
Summary: [GStreamer][DMABuf] AV1 video is broken with the dav1d decoder
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Local Build
Hardware: PC Linux
: P2 Normal
Assignee: Philippe Normand
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-16 06:12 PDT by Xi Ruoyao
Modified: 2023-06-24 09:27 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xi Ruoyao 2023-06-16 06:12:45 PDT
With WebKitGTK-2.41.5 (built with GTK-4.10.4) and the dav1ddec AV1 decoder (from gst-plugins-rs-0.10.8, built with dav1d-1.2.1), when I open an AV1 video in MiniBrowser, the video is played in a broken way (some greenish color) for several seconds, then WebKitWebProcess crashes.

If I set WEBKIT_GST_DMABUF_SINK_DISABLED=1, the video is played normally.
Comment 1 Xi Ruoyao 2023-06-16 06:24:21 PDT
Note that with dav1d plugin removed, the video can be played with the libaom plugin w/o bad color nor crashing. But the performance of libaom plugin is too bad so I cannot use it in practice.  And my hardware lacks AV1 decoding function so I cannot test the VA-API decoder.
Comment 2 Philippe Normand 2023-06-16 09:20:11 PDT
Can you share a link to that AV1 asset?
Comment 3 Xi Ruoyao 2023-06-16 09:29:00 PDT
(In reply to Philippe Normand from comment #2)
> Can you share a link to that AV1 asset?

I can reproduce the issue by 

wget https://github.com/SPBTV/video_av1_samples/raw/master/spbtv_sample_bipbop_av1_960x540_25fps.mp4 -O test.mp4
python3 -m http.server &
/usr/libexec/webkitgtk-6.0/MiniBrowser http://127.0.0.1:8000/test.mp4

Basically it happens with any AV1 video for me.  But perhaps the issue is related to some of my local configuration if you cannot reproduce it.
Comment 4 Philippe Normand 2023-06-16 10:02:17 PDT
I got a crash in release after seeing a couple green frames. Wasn't able to make it crash in debug.

#0  __memcpy_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:265                                                                                                                   
265             VMOVU   (%rsi), %VMM(0) 

(gdb) bt                                                                                                                                                                                                             
#0  __memcpy_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:265                                                                                                                   
#1  0x00007fc9709d7dcc in WebCore::MediaPlayerPrivateGStreamer::pushDMABufToCompositor() () at /var/home/phil/WebKit/WebKitBuild/GTK/Release/lib/libwebkit2gtk-4.1.so.0                                              
#2  0x00007fc9709d90d5 in WebCore::MediaPlayerPrivateGStreamer::triggerRepaint(WTF::GRefPtr<_GstSample>&&) () at /var/home/phil/WebKit/WebKitBuild/GTK/Release/lib/libwebkit2gtk-4.1.so.0                            
#3  0x00007fc9709c0aae in webKitVideoSinkSetMediaPlayerPrivate(_GstElement*, WebCore::MediaPlayerPrivateGStreamer*)::$_1::__invoke(_GstElement*, WebCore::MediaPlayerPrivateGStreamer*) ()                           
    at /var/home/phil/WebKit/WebKitBuild/GTK/Release/lib/libwebkit2gtk-4.1.so.0                                                                                                                                      
#4  0x00007fc9656b1be6 in ffi_call_unix64 () at ../src/x86/unix64.S:104                                                                                                                                              
#5  0x00007fc9656ae4bf in ffi_call_int (cif=cif@entry=0x7fc87e41b580, fn=<optimized out>, rvalue=<optimized out>, avalue=<optimized out>, closure=closure@entry=0x0) at ../src/x86/ffi64.c:673                       
#6  0x00007fc9656b118e in ffi_call                                                                                                                                                                                   
    (cif=cif@entry=0x7fc87e41b580, fn=fn@entry=0x7fc9709c0a70 <webKitVideoSinkSetMediaPlayerPrivate(_GstElement*, WebCore::MediaPlayerPrivateGStreamer*)::$_1::__invoke(_GstElement*, WebCore::MediaPlayerPrivateGStr
eamer*)>, rvalue=rvalue@entry=0x7fc87e41b4e0, avalue=avalue@entry=0x7fc87e41b4a0) at ../src/x86/ffi64.c:710                                                                                                          
#7  0x00007fc96d406113 in g_cclosure_marshal_generic_va                                                                                                                                                              
    (closure=<optimized out>, return_value=<optimized out>, instance=<optimized out>, args_list=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=<optimized out>)                
    at ../gobject/gclosure.c:1650                                                                                                                                                                                    
#8  0x00007fc96d41d608 in _g_closure_invoke_va (param_types=0x0, n_params=<optimized out>, args=0x7fc87e41b790, instance=0xb21590, return_value=0x7fc87e41b6c0, closure=0xb22410) at ../gobject/gclosure.c:895       
#9  g_signal_emit_valist (instance=0xb21590, signal_id=259, detail=0, var_args=var_args@entry=0x7fc87e41b790) at ../gobject/gsignal.c:3462                                                                           
#10 0x00007fc96d41d6f3 in g_signal_emit (instance=instance@entry=0xb21590, signal_id=<optimized out>, detail=detail@entry=0) at ../gobject/gsignal.c:3612                                                            
#11 0x00007fc9685635c3 in gst_app_sink_render_common (psink=0xb21590, data=0x7fc8840a3060 [None], is_list=<optimized out>) at ../gst-libs/gst/app/gstappsink.c:1103                                                  
#12 0x00007fc96853ad2d in gst_base_sink_chain_unlocked.isra.0 (basesink=0xb21590, obj=0x7fc8840a3060, is_list=0, pad=<optimized out>) at ../libs/gst/base/gstbasesink.c:3952                                         
#13 0x00007fc968508bde in gst_base_sink_chain_main (basesink=0xb21590, pad=<optimized out>, obj=0x7fc8840a3060, is_list=0) at ../libs/gst/base/gstbasesink.c:4078                                                    
#14 0x00007fc96841aa1c in gst_pad_chain_data_unchecked (pad=pad@entry=0xb21900, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4463                                                        
#15 0x00007fc96841b7ae in gst_pad_push_data (pad=pad@entry=0xb24290, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4739                                                                   
#16 0x00007fc96841bde4 in gst_pad_push (pad=0xb24290, buffer=0x7fc8840a3060 [None]) at ../gst/gstpad.c:4858                                                                                                          
#17 0x00007fc9683ff1bb in gst_proxy_pad_chain_default (pad=pad@entry=0xb23e70, parent=parent@entry=0xb20c70, buffer=buffer@entry=0x7fc8840a3060 [None]) at ../gst/gstghostpad.c:127                                  
#18 0x00007fc96841aa1c in gst_pad_chain_data_unchecked (pad=pad@entry=0xb23e70, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4463                                                        
#19 0x00007fc96841b7ae in gst_pad_push_data (pad=pad@entry=0x7fc880007eb0, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4739                                                             
#20 0x00007fc96841bde4 in gst_pad_push (pad=0x7fc880007eb0, buffer=0x7fc8840a3060 [None]) at ../gst/gstpad.c:4858                                                                                                    
#21 0x00007fc9683ff1bb in gst_proxy_pad_chain_default (pad=pad@entry=0x7fc880008f30, parent=parent@entry=0x7fc880007eb0, buffer=buffer@entry=0x7fc8840a3060 [None]) at ../gst/gstghostpad.c:127                      
#22 0x00007fc96841aa1c in gst_pad_chain_data_unchecked (pad=pad@entry=0x7fc880008f30, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4463                                                  
#23 0x00007fc96841b7ae in gst_pad_push_data (pad=pad@entry=0x7fc880045310, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4739                                                             
#24 0x00007fc96841bde4 in gst_pad_push (pad=0x7fc880045310, buffer=0x7fc8840a3060 [None]) at ../gst/gstpad.c:4858                                                                                                    
#25 0x00007fc968516a7c in gst_base_transform_chain (pad=pad@entry=0x7fc880044ee0, parent=parent@entry=0x7fc880044b00, buffer=buffer@entry=0x7fc8840a3060 [None]) at ../libs/gst/base/gstbasetransform.c:2391         
#26 0x00007fc96841aa1c in gst_pad_chain_data_unchecked (pad=pad@entry=0x7fc880044ee0, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4463                                                  
#27 0x00007fc96841b7ae in gst_pad_push_data (pad=pad@entry=0x7fc8800138a0, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4739                                                             
#28 0x00007fc96841bde4 in gst_pad_push (pad=0x7fc8800138a0, buffer=0x7fc8840a3060 [None]) at ../gst/gstpad.c:4858                                                                                                    
#29 0x00007fc968516a7c in gst_base_transform_chain (pad=pad@entry=0x7fc8800134b0, parent=parent@entry=0x7fc880011f70, buffer=buffer@entry=0x7fc8840a3060 [None]) at ../libs/gst/base/gstbasetransform.c:2391         
#30 0x00007fc96841aa1c in gst_pad_chain_data_unchecked (pad=pad@entry=0x7fc8800134b0, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4463                                                  
#31 0x00007fc96841b7ae in gst_pad_push_data (pad=pad@entry=0x7fc880044690, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4739                                                             
#32 0x00007fc96841bde4 in gst_pad_push (pad=0x7fc880044690, buffer=0x7fc8840a3060 [None]) at ../gst/gstpad.c:4858                                                                                                    
#33 0x00007fc968516a7c in gst_base_transform_chain (pad=pad@entry=0x7fc880044420, parent=parent@entry=0x7fc880044040, buffer=buffer@entry=0x7fc8840a3060 [None]) at ../libs/gst/base/gstbasetransform.c:2391         
#34 0x00007fc96841aa1c in gst_pad_chain_data_unchecked (pad=pad@entry=0x7fc880044420, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4463                                                  
#35 0x00007fc96841b7ae in gst_pad_push_data (pad=pad@entry=0x7fc880043c90, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4739                                                             
#36 0x00007fc96841bde4 in gst_pad_push (pad=0x7fc880043c90, buffer=0x7fc8840a3060 [None]) at ../gst/gstpad.c:4858                                                                                                    
#37 0x00007fc968516a7c in gst_base_transform_chain (pad=pad@entry=0x7fc88003c560, parent=parent@entry=0x7fc88003b070, buffer=buffer@entry=0x7fc8840a3060 [None]) at ../libs/gst/base/gstbasetransform.c:2391         
#38 0x00007fc96841aa1c in gst_pad_chain_data_unchecked (pad=pad@entry=0x7fc88003c560, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4463                                                  
#39 0x00007fc96841b7ae in gst_pad_push_data (pad=pad@entry=0x7fc88000b540, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4739                                                             
#40 0x00007fc96841bde4 in gst_pad_push (pad=0x7fc88000b540, buffer=0x7fc8840a3060 [None]) at ../gst/gstpad.c:4858                                                                                                    
#41 0x00007fc9683ff1bb in gst_proxy_pad_chain_default (pad=pad@entry=0x7fc880009960, parent=parent@entry=0x7fc88000b0a0, buffer=buffer@entry=0x7fc8840a3060 [None]) at ../gst/gstghostpad.c:127                      
#42 0x00007fc96841aa1c in gst_pad_chain_data_unchecked (pad=pad@entry=0x7fc880009960, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4463                                                  
#43 0x00007fc96841b7ae in gst_pad_push_data (pad=pad@entry=0x7fc88000a160, type=type@entry=4112, data=data@entry=0x7fc8840a3060) at ../gst/gstpad.c:4739                                                             
#44 0x00007fc96841bde4 in gst_pad_push (pad=0x7fc88000a160, buffer=buffer@entry=0x7fc8840a3060 [None]) at ../gst/gstpad.c:4858                                                                                       
#45 0x00007fc8e00a4ea9 in gst_queue_push_one (queue=0x7fc880006b10) at ../plugins/elements/gstqueue.c:1388
#46 gst_queue_loop (pad=<optimized out>) at ../plugins/elements/gstqueue.c:1541                                                                                                                                      
#47 0x00007fc968454ee4 in gst_task_func (task=0x7fc88005ec30) at ../gst/gsttask.c:384                                                                                                                                
#48 0x00007fc96925db02 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:350                                                                                                             
#49 0x00007fc96925b373 in g_thread_proxy (data=0x7fc944001b90) at ../glib/gthread.c:831                                                                                                                              
#50 0x00007fc968d24c57 in start_thread (arg=<optimized out>) at pthread_create.c:444                                                                                                                                 
#51 0x00007fc968daaa70 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Comment 5 Philippe Normand 2023-06-17 07:10:34 PDT
Pull request: https://github.com/WebKit/WebKit/pull/15070
Comment 6 Xi Ruoyao 2023-06-17 08:05:42 PDT
(In reply to Philippe Normand from comment #5)
> Pull request: https://github.com/WebKit/WebKit/pull/15070

Confirm the change is able to fix the issue.  Thanks for the swift response!
Comment 7 EWS 2023-06-19 00:36:53 PDT
Committed 265296@main (ba6c5b004983): <https://commits.webkit.org/265296@main>

Reviewed commits have been landed. Closing PR #15070 and removing active labels.
Comment 8 Xi Ruoyao 2023-06-24 05:11:43 PDT
Ouch, while this commit indeed fixes the issue with AOM decoder, it caused a regression with VA-API decoder.

I applied the commit as a patch onto WebKitGTK-2.41.5, then on a system with hardware AV1 decoding capability:

wget https://github.com/SPBTV/video_av1_samples/raw/master/spbtv_sample_bipbop_av1_960x540_25fps.mp4 -O test.mp4
python3 -m http.server &
GST_PLUGIN_FEATURE_RANK=vaav1dec:MAX /usr/libexec/webkitgtk-6.0/MiniBrowser http://127.0.0.1:8000/test.mp4

The video is shown as completely green.

I'm not sure if I've done something wrong (maybe I need to backport more patches to support this change), or this is indeed a regression.  Should I create another ticket?
Comment 9 Philippe Normand 2023-06-24 07:03:56 PDT
Did you backport ba6c5b004983 or an earlier version of the PR?

The first patch I submitted indeed broke VA (vavp9dec at least), but the second one, the one that landed, didn't. I can test again vavp9dec, but I don't have hw AV1 decoder here, can't test vaav1.
Comment 10 Philippe Normand 2023-06-24 09:10:29 PDT
vavp9dec still works fine here.
Comment 11 Xi Ruoyao 2023-06-24 09:14:04 PDT
Ouch, I backported 7dbe772 and I guess this is my undoing.
Comment 12 Xi Ruoyao 2023-06-24 09:27:52 PDT
Confirm ba6c5b004983 is fine.  Sorry for noise.