Bug 211155 - PlatformMediaResourceLoader should be destroyed on the main thread
Summary: PlatformMediaResourceLoader should be destroyed on the main thread
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alicia Boya García
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-28 17:00 PDT by Alicia Boya García
Modified: 2020-04-29 04:34 PDT (History)
13 users (show)

See Also:


Attachments
Patch (3.54 KB, patch)
2020-04-28 17:07 PDT, Alicia Boya García
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alicia Boya García 2020-04-28 17:00:48 PDT
PlatformMediaResourceLoader is only safe to use from the main thread.
A tricky detail is this includes its destruction. The same is true for
PlatformMediaResource.

Both classes are ThreadSafeRefCounted<> classes and therefore
WTF::DestructionThread::Main can be used to ensure destruction is run
in the correct thread with no need for additional client code.

* platform/graphics/PlatformMediaResourceLoader.h:
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(WebKitWebSrcPrivate::StreamingMembers::~StreamingMembers):
Comment 1 Alicia Boya García 2020-04-28 17:06:03 PDT
Backtrace of the crash that made me find the bug:

#0  WTFCrash () at ../../Source/WTF/wtf/Assertions.cpp:309
#1  0x000000007b93caec in CRASH_WITH_INFO(...) () at DerivedSources/ForwardingHeaders/wtf/Assertions.h:713
#2  0x000000007e1bb2c0 in WebCore::ContextDestructionObserver::observeContext (this=0x7fcd49942f70, scriptExecutionContext=0x0) at ../../Source/WebCore/dom/ContextDestructionObserver.cpp:48
#3  0x000000007e1bb225 in WebCore::ContextDestructionObserver::~ContextDestructionObserver (this=0x7fcd49942f70, __in_chrg=<optimized out>) at ../../Source/WebCore/dom/ContextDestructionObserver.cpp:42
#4  0x000000007ea4dd79 in WebCore::MediaResourceLoader::~MediaResourceLoader (this=0x7fcd49942f50, __in_chrg=<optimized out>) at ../../Source/WebCore/loader/MediaResourceLoader.cpp:59
#5  0x000000007ea4ddba in WebCore::MediaResourceLoader::~MediaResourceLoader (this=0x7fcd49942f50, __in_chrg=<optimized out>) at ../../Source/WebCore/loader/MediaResourceLoader.cpp:62
#6  0x000000007cd2421c in WTF::ThreadSafeRefCounted<WebCore::PlatformMediaResourceLoader, (WTF::DestructionThread)0>::deref() const::{lambda()#1}::operator()() const (this=0x7fcd49942f58)
    at DerivedSources/ForwardingHeaders/wtf/ThreadSafeRefCounted.h:117
#7  0x000000007cd24254 in WTF::ThreadSafeRefCounted<WebCore::PlatformMediaResourceLoader, (WTF::DestructionThread)0>::deref (this=0x7fcd49942f58) at DerivedSources/ForwardingHeaders/wtf/ThreadSafeRefCounted.h:135
#8  0x000000007cd23714 in WTF::derefIfNotNull<WebCore::PlatformMediaResourceLoader> (ptr=0x7fcd49942f50) at DerivedSources/ForwardingHeaders/wtf/RefPtr.h:44
#9  0x000000007cd231a7 in WTF::RefPtr<WebCore::PlatformMediaResourceLoader, WTF::DumbPtrTraits<WebCore::PlatformMediaResourceLoader> >::operator=(decltype(nullptr)) (this=0x1cb98e0) at DerivedSources/ForwardingHeaders/wtf/RefPtr.h:156
#10 0x000000007cd1d567 in webKitWebSrcUnLock (baseSrc=0x1cb99d0 [GstBaseSrc|source]) at ../../Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:829
#11 0x00007fcd4968a77e in gst_base_src_set_flushing (basesrc=0x1cb99d0 [GstBaseSrc|source], flushing=1) at ../subprojects/gstreamer/libs/gst/base/gstbasesrc.c:3735
#12 0x00007fcd496836ee in gst_base_src_perform_seek (src=0x1cb99d0 [GstBaseSrc|source], event=0xb9064006b20, unlock=1) at ../subprojects/gstreamer/libs/gst/base/gstbasesrc.c:1674
#13 0x00007fcd49684951 in gst_base_src_default_event (src=0x1cb99d0 [GstBaseSrc|source], event=0xb9064006b20) at ../subprojects/gstreamer/libs/gst/base/gstbasesrc.c:2050
#14 0x00007fcd49684ab0 in gst_base_src_event (pad=0x11357013a860 [GstPad|src], parent=0x1cb99d0 [GstObject|source], event=0xb9064006b20) at ../subprojects/gstreamer/libs/gst/base/gstbasesrc.c:2102
#15 0x000069e50c7611c4 in gst_pad_send_event_unchecked (pad=0x11357013a860 [GstPad|src], event=0xb9064006b20, type=GST_PAD_PROBE_TYPE_EVENT_UPSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5840
#16 0x000069e50c75fae0 in gst_pad_push_event_unchecked (pad=0x3a0f800565a0 [GstPad|sink], event=0xb9064006b20, type=GST_PAD_PROBE_TYPE_EVENT_UPSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5484
#17 0x000069e50c76032c in gst_pad_push_event (pad=0x3a0f800565a0 [GstPad|sink], event=0xb9064006b20) at ../subprojects/gstreamer/gst/gstpad.c:5621
#18 0x00006b89540929b1 in gst_type_find_element_src_event (pad=0x3a0f8008bc20 [GstPad|src], parent=0x21be3e0 [GstObject|typefindelement2], event=0xb9064006b20) at ../subprojects/gstreamer/plugins/elements/gsttypefindelement.c:568
#19 0x000069e50c7611c4 in gst_pad_send_event_unchecked (pad=0x3a0f8008bc20 [GstPad|src], event=0xb9064006b20, type=GST_PAD_PROBE_TYPE_EVENT_UPSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5840
#20 0x000069e50c75fae0 in gst_pad_push_event_unchecked (pad=0x21ba5e0 [GstPad|sink], event=0xb9064006b20, type=GST_PAD_PROBE_TYPE_EVENT_UPSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5484
#21 0x000069e50c76032c in gst_pad_push_event (pad=0x21ba5e0 [GstPad|sink], event=0xb9064006b20) at ../subprojects/gstreamer/gst/gstpad.c:5621
#22 0x00006b8954049249 in perform_seek_to_offset (dlbuf=0x4b1a2403c930 [GstDownloadBuffer|downloadbuffer1], offset=3740178) at ../subprojects/gstreamer/plugins/elements/gstdownloadbuffer.c:630
#23 0x00006b8954049555 in gst_download_buffer_wait_for_data (dlbuf=0x4b1a2403c930 [GstDownloadBuffer|downloadbuffer1], offset=3740178, length=16) at ../subprojects/gstreamer/plugins/elements/gstdownloadbuffer.c:704
#24 0x00006b8954049df5 in gst_download_buffer_read_buffer (dlbuf=0x4b1a2403c930 [GstDownloadBuffer|downloadbuffer1], offset=3740178, length=16, buffer=0x53cb1ac0e060) at ../subprojects/gstreamer/plugins/elements/gstdownloadbuffer.c:803
#25 0x00006b895404d365 in gst_download_buffer_get_range (pad=0x3a0f800567f0 [GstPad|src], parent=0x4b1a2403c930 [GstObject|downloadbuffer1], offset=3740178, length=16, buffer=0x53cb1ac0e060)
    at ../subprojects/gstreamer/plugins/elements/gstdownloadbuffer.c:1643
#26 0x000069e50c75d6a0 in gst_pad_get_range_unchecked (pad=0x3a0f800567f0 [GstPad|src], offset=3740178, size=16, buffer=0x53cb1ac0e100) at ../subprojects/gstreamer/gst/gstpad.c:4864
#27 0x000069e50c75e3f3 in gst_pad_pull_range (pad=0x11357013c580 [GstPad|proxypad61], offset=3740178, size=16, buffer=0x53cb1ac0e280) at ../subprojects/gstreamer/gst/gstpad.c:5105
#28 0x000069e50c739ca0 in gst_proxy_pad_getrange_default (pad=0x113570137380 [GstPad|src_0], parent=0x4b1a240382f0 [GstObject|urisourcebin2], offset=3740178, size=16, buffer=0x53cb1ac0e280)
    at ../subprojects/gstreamer/gst/gstghostpad.c:185
#29 0x000069e50c75d6a0 in gst_pad_get_range_unchecked (pad=0x113570137380 [GstPad|src_0], offset=3740178, size=16, buffer=0x53cb1ac0e320) at ../subprojects/gstreamer/gst/gstpad.c:4864
#30 0x000069e50c75e3f3 in gst_pad_pull_range (pad=0x1ba0dc0 [GstPad|sink], offset=3740178, size=16, buffer=0x53cb1ac0e4a0) at ../subprojects/gstreamer/gst/gstpad.c:5105
#31 0x000069e50c739ca0 in gst_proxy_pad_getrange_default (pad=0x1c190f0 [GstPad|proxypad5], parent=0x1ba0dc0 [GstObject|sink], offset=3740178, size=16, buffer=0x53cb1ac0e4a0) at ../subprojects/gstreamer/gst/gstghostpad.c:185
#32 0x000069e50c75d6a0 in gst_pad_get_range_unchecked (pad=0x1c190f0 [GstPad|proxypad5], offset=3740178, size=16, buffer=0x53cb1ac0e540) at ../subprojects/gstreamer/gst/gstpad.c:4864
#33 0x000069e50c75e3f3 in gst_pad_pull_range (pad=0x113570137b00 [GstPad|sink], offset=3740178, size=16, buffer=0x53cb1ac0e6c0) at ../subprojects/gstreamer/gst/gstpad.c:5105
#34 0x000069e50c739ca0 in gst_proxy_pad_getrange_default (pad=0x1c19cd0 [GstPad|proxypad62], parent=0x113570137b00 [GstObject|sink], offset=3740178, size=16, buffer=0x53cb1ac0e6c0) at ../subprojects/gstreamer/gst/gstghostpad.c:185
#35 0x000069e50c75d6a0 in gst_pad_get_range_unchecked (pad=0x1c19cd0 [GstPad|proxypad62], offset=3740178, size=16, buffer=0x53cb1ac0e760) at ../subprojects/gstreamer/gst/gstpad.c:4864
#36 0x000069e50c75e3f3 in gst_pad_pull_range (pad=0x21ba390 [GstPad|sink], offset=3740178, size=16, buffer=0x53cb1ac0e8c0) at ../subprojects/gstreamer/gst/gstpad.c:5105
#37 0x00006b8954094243 in gst_type_find_element_getrange (srcpad=0x21bacd0 [GstPad|src], parent=0x21be980 [GstObject|typefind], offset=3740178, length=16, buffer=0x53cb1ac0e8c0)
    at ../subprojects/gstreamer/plugins/elements/gsttypefindelement.c:1045
#38 0x000069e50c75d6a0 in gst_pad_get_range_unchecked (pad=0x21bacd0 [GstPad|src], offset=3740178, size=16, buffer=0x53cb1ac0e960) at ../subprojects/gstreamer/gst/gstpad.c:4864
#39 0x000069e50c75e3f3 in gst_pad_pull_range (pad=0x1ba7d70 [GstPad|sink], offset=3740178, size=16, buffer=0x53cb1ac0eab0) at ../subprojects/gstreamer/gst/gstpad.c:5105
#40 0x00007fcd4ac9ab5c in gst_qtdemux_loop_state_header (qtdemux=0x1135700395e0 [GstQTDemux|qtdemux2]) at ../subprojects/gst-plugins-good/gst/isomp4/qtdemux.c:4568
#41 0x00007fcd4aca57c2 in gst_qtdemux_loop (pad=0x1ba7d70 [GstPad|sink]) at ../subprojects/gst-plugins-good/gst/isomp4/qtdemux.c:6602
#42 0x000069e50c79a36d in gst_task_func (task=0x4b1a240a3950 [GstTask|qtdemux2:sink]) at ../subprojects/gstreamer/gst/gsttask.c:328
#43 0x000069e50c79b54f in default_func (tdata=0x3a0f8005a030, pool=0x1a26f30 [GstTaskPool|taskpool0]) at ../subprojects/gstreamer/gst/gsttaskpool.c:70
#44 0x00005f5110e2c4e4 in g_thread_pool_thread_proxy () at ../../Source/glib-2.58.1/glib/gthreadpool.c:307
#45 0x00005f5110e2bb65 in g_thread_proxy () at ../../Source/glib-2.58.1/glib/gthread.c:784
#46 0x000079681a1da4e2 in start_thread (arg=<optimized out>) at pthread_create.c:479
#47 0x00007ad64ab3a6d3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Comment 2 Alicia Boya García 2020-04-28 17:07:07 PDT
Created attachment 397910 [details]
Patch
Comment 3 EWS 2020-04-29 04:33:50 PDT
Committed r260892: <https://trac.webkit.org/changeset/260892>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397910 [details].
Comment 4 Radar WebKit Bug Importer 2020-04-29 04:34:12 PDT
<rdar://problem/62590820>