WebPlatformForEmbedded / WPEWebKit

WPE WebKit port (downstream)
213 stars 136 forks source link

[wpe-2.38][mse] hang on early seek #1367

Open emutavchi opened 1 month ago

emutavchi commented 1 month ago

Can be reproduced with attached mse_hang.html.gz. It is reproducible randomly, but usually within first 100 iterations

Browser main thread is blocked on playsink data prob that is awaiting for data flow on another pad:

Thread 1 (Thread 18419.18419 "WPEWebProcess"):
#0  syscall () at ../sysdeps/unix/sysv/linux/arm/syscall.S:37
#1  0xb2cf1ee8 in g_cond_wait (cond=cond@entry=0x38e7d4, mutex=mutex@entry=0x38e784) at ../glib-2.62.6/glib/gthread-posix.c:1422
#2  0xb2b7c34e in do_probe_callbacks (pad=pad@entry=0x38e778, info=info@entry=0xbed95728, defaultval=defaultval@entry=GST_FLOW_OK) at ../gstreamer-1.18.5/gst/gstpad.c:3851
#3  0xb2b7ec9a in gst_pad_push_event_unchecked (pad=pad@entry=0x38e778, event=0xac905098, type=type@entry=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../gstreamer-1.18.5/gst/gstpad.c:5448
#4  0xb2b7f228 in push_sticky (pad=0x38e778, ev=0xbed957b8, user_data=0xbed957fc) at ../gstreamer-1.18.5/gst/gstpad.c:4004
#5  0xb2b7d3bc in events_foreach (pad=pad@entry=0x38e778, func=0xb2b7f1e5 <push_sticky>, user_data=user_data@entry=0xbed957fc) at ../gstreamer-1.18.5/gst/gstpad.c:608
#6  0xb2b85a74 in check_sticky (event=0xac905098, pad=0x38e778) at ../gstreamer-1.18.5/gst/gstpad.c:4063
#7  gst_pad_push_event (pad=pad@entry=0x38e778, event=0xac905098) at ../gstreamer-1.18.5/gst/gstpad.c:5632
#8  0xb2b85d76 in event_forward_func (pad=0x38e778, data=0xbed958d4) at ../gstreamer-1.18.5/gst/gstpad.c:3125
...
#75 0xb40e5934 in webKitMediaSrcStreamFlush () at ../git/Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:950
#76 0xb40e6060 in webKitMediaSrcSeek () at ../git/Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:983
#77 webKitMediaSrcSendEvent () at ../git/Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:1047
#78 0xb2b68c16 in gst_element_send_event (element=0x386948, event=0x3976b0) at ../gstreamer-1.18.5/gst/gstelement.c:1947
#79 0xb40e02ae in WebCore::MediaPlayerPrivateGStreamerMSE::doSeek () at ../git/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:277
#80 0xb40ded7a in WebCore::MediaPlayerPrivateGStreamerMSE::seek () at ../git/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:247
#81 0xb4b407da in WebCore::HTMLMediaElement::seekTask () at ../git/Source/WebCore/html/HTMLMediaElement.cpp:3356
#82 0xb4a01806 in WTF::Function<void ()>::operator()() const () at WTF/Headers/wtf/Function.h:82
#83 WebCore::EventLoopFunctionDispatchTask::execute () at ../git/Source/WebCore/dom/EventLoop.cpp:160
#84 WebCore::EventLoop::run () at ../git/Source/WebCore/dom/EventLoop.cpp:124
#85 0xb4a456be in WebCore::WindowEventLoop::didReachTimeToRun () at ../git/Source/WebCore/dom/WindowEventLoop.cpp:121
#86 0xb4dc0854 in WebCore::ThreadTimers::sharedTimerFiredInternal () at ../git/Source/WebCore/platform/ThreadTimers.cpp:127
#87 0xb4060362 in operator() () at ../git/Source/WTF/wtf/glib/RunLoopGLib.cpp:177
#88 _FUN () at ../git/Source/WTF/wtf/glib/RunLoopGLib.cpp:181
#89 0xb4060930 in operator() () at ../git/Source/WTF/wtf/glib/RunLoopGLib.cpp:53
#90 _FUN () at ../git/Source/WTF/wtf/glib/RunLoopGLib.cpp:56
#91 0xb2cbf022 in g_main_dispatch (context=0x3e090) at ../glib-2.62.6/glib/gmain.c:3216
#92 g_main_context_dispatch (context=context@entry=0x3e090) at ../glib-2.62.6/glib/gmain.c:3881
#93 0xb2cbf278 in g_main_context_iterate (context=0x3e090, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib-2.62.6/glib/gmain.c:3954
#94 0xb2cbf4c8 in g_main_loop_run (loop=0x46a78) at ../glib-2.62.6/glib/gmain.c:4148
#95 0xb4060bd0 in WTF::RunLoop::run () at ../git/Source/WTF/wtf/glib/RunLoopGLib.cpp:108
#96 0xb37f43f2 in WebKit::AuxiliaryProcessMainBase<WebKit::WebProcess, true>::run () at ../git/Source/WebKit/Shared/AuxiliaryProcessMain.h:71
#97 WebKit::AuxiliaryProcessMainBase<WebKit::WebProcess, true>::run () at ../git/Source/WebKit/Shared/AuxiliaryProcessMain.h:58
#98 WebKit::AuxiliaryProcessMain<WebKit::WebProcessMainWPE> () at ../git/Source/WebKit/Shared/AuxiliaryProcessMain.h:97
#99 0xb37f4422 in WebKit::WebProcessMain () at ../git/Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp:75
#100 0xb30ed9e4 in __libc_start_main (main=0x104d5 <main()>, argc=3, argv=0xbed97624, init=<optimized out>, fini=0x105d9 <__libc_csu_fini>, rtld_fini=0xb6faae25 <_dl_fini>, stack_end=0xbed97624) at libc-start.c:308
#101 0x000104f8 in _start () at ../sysdeps/arm/start.S:126

all_bt.txt.gz

emutavchi commented 1 month ago

We use attached patch as workaround with GStreamer 1.18.5: fix-deadlock-on-early-flushing-seek.patch.gz

eocanha commented 1 month ago

I haven't been able to reproduce the issue even after 500 repetitions. I might try to blindly include that patch in our set of buildroot custom patches, but the problem you describe is suspicioulsy similar to the one reported in https://bugs.webkit.org/show_bug.cgi?id=272975 / https://github.com/WebKit/WebKit/pull/27517 (a problem with a half-configured playsink when flush happens). GStreamer MR https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6763 also seems to fix it, and is half-way into being approved and merged. Can you check if that fix would work in your case?