Bug 265503 - m_parser can be concurrently accessed bu SourceBufferPrivateAVFObjC
Summary: m_parser can be concurrently accessed bu SourceBufferPrivateAVFObjC
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jean-Yves Avenard [:jya]
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-11-28 20:53 PST by Jean-Yves Avenard [:jya]
Modified: 2023-11-29 04:40 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Yves Avenard [:jya] 2023-11-28 20:53:45 PST
Seen in a few EWS run
https://build.webkit.org/results/Apple-Ventura-Debug-WK2-Tests/271159@main%20(3493)/media/media-source/media-source-first-sample-pts-non-zero-canplay-without-renderer-crash-log.txt

```
0  com.apple.JavaScriptCore	       0x10be3e41e    WTFCrash
1  com.apple.JavaScriptCore	       0x10be604d2    ReportBlockedObjCException(NSException*)
2  com.apple.WebCore       	       0x19e8f2e8c    WebCore::SourceBufferParserAVFObjC::setShouldProvideMediaDataForTrackID(bool, unsigned long long)
3  com.apple.WebCore       	       0x19e908d90    WebCore::SourceBufferPrivateAVFObjC::trackDidChangeSelected(WebCore::VideoTrackPrivate&, bool)
4  com.apple.WebCore       	       0x19e926ef2    WebCore::SourceBufferPrivateAVFObjC::setTrackChangeCallbacks(WebCore::SourceBufferPrivateClient::InitializationSegment const&, bool)::$_9::operator()(WebCore::VideoTrackPrivate&, bool)::'lambda'()::operator()() const
5  com.apple.WebCore       	       0x19e926c68    WTF::Detail::CallableWrapper<WebCore::SourceBufferPrivateAVFObjC::setTrackChangeCallbacks(WebCore::SourceBufferPrivateClient::InitializationSegment const&, bool)::$_9::operator()(WebCore::VideoTrackPrivate&, bool)::'lambda'(), void>::call()
6  com.apple.WebCore       	       0x19e36d3a2    WTF::Function<void ()>::operator()() const
7  com.apple.WebCore       	       0x19e903f7e    WebCore::SourceBufferPrivateAVFObjC::processInitialisationSegment(std::__1::optional<WebCore::SourceBufferPrivateClient::InitializationSegment>&&)
8  com.apple.WebCore       	       0x1a320f0ea    auto WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13::operator()<std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>>(std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>)
9  com.apple.WebCore       	       0x1a320efe2    decltype(std::declval<WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13>()(std::declval<std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>>())) std::__1::__invoke[abi:v15006]<WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13, std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>>(WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13&&, std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>&&)
10  com.apple.WebCore       	       0x1a320ef98    std::__1::invoke_result<WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13, std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>>::type std::__1::invoke<WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13, std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>>(WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13&&, std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>&&)
11  com.apple.WebCore       	       0x1a320ef58    auto WTF::NativePromise<void, WebCore::PlatformMediaError, 0u>::invokeWithVoidOrWithArg<WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13, std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>>(WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13&&, std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>&&)
12  com.apple.WebCore       	       0x1a320ef20    auto WTF::NativePromise<void, WebCore::PlatformMediaError, 0u>::whenSettled<WTF::RunLoop, WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13>(WTF::RunLoop&, WebCore::SourceBufferPrivate::didReceiveInitializationSegment(WebCore::SourceBufferPrivateClient::InitializationSegment&&)::$_13&&, WTF::Logger::LogSiteIdentifier const&)::'lambda'(std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>&&)::operator()('lambda'(std::experimental::fundamentals_v3::expected<void, WebCore::PlatformMediaError>&&))
```

When an init segment is received, and after it's been sent back to the content process to build the Audio/Video TrackBufferList , the SourceBufferPrivateObjC calls `[m_parser setShouldProvideMediaData:]` on the main thread.

However, m_parser needs to be operating on the parsing queue and could be in the middle of processing the appended buffer.

In addition, this call doesn't make much sense in an asynchronous world, by the time the init segment has been processed, in most cases the SourceBufferParser would have fulled demuxed the content and can't go back and demux more frames from tracks that used to be disabled.

We don't want to unnecessarily demuxed frames from tracks that have been disabled, and the real-world usage is that different sourceBuffer would be used when dealing with disabled tracks.

The SourceBufferParserWebM also don't implement that method.

It's best to completely ignore the tracks that are disabled in the container, they are extremely uncommon and our current handling of those means they would always be ignored anyway.
Comment 1 Radar WebKit Bug Importer 2023-11-28 20:54:08 PST
<rdar://problem/118913735>
Comment 2 Jean-Yves Avenard [:jya] 2023-11-28 22:49:18 PST
Pull request: https://github.com/WebKit/WebKit/pull/21044
Comment 3 EWS 2023-11-29 04:40:51 PST
Committed 271270@main (98e1d7550182): <https://commits.webkit.org/271270@main>

Reviewed commits have been landed. Closing PR #21044 and removing active labels.