Bug 239474

Summary: [ macOS ] TestWebKitAPI.WebKit2.SpeechRecognitionErrorWhenStartingAudioCaptureOnDifferentPageE is a flaky crash
Product: WebKit Reporter: Karl Rackler <rackler>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, sihui_liu, webkit-bot-watchers-bugzilla, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Karl Rackler 2022-04-18 16:49:22 PDT
Description:
This API test is a flaky crash on [ macOS ] bots

The first crash that I see on the dashboard for Monterey was 3/18/2022 at r291517, and for BigSur 2/22/2022 at r290314.  There was not one commit that I observe causing this issue.  This test seems to have been flaky since the start.

History: 
https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.WebKit2.SpeechRecognitionErrorWhenStartingAudioCaptureOnDifferentPage&limit=50000&platform=mac

Crash Log:
Bot failed to capture the crash log with:
Test suite failed
Crashed
    TestWebKitAPI.WebKit2.SpeechRecognitionErrorWhenStartingAudioCaptureOnDifferentPage

Pulled the crash log off the bot: 
Thread 4 Crashed::  Dispatch queue: MockAudioSharedUnit Capture Queue
0   WebCore                       	       0x115aac6b4 _cxx_atomic_fetch_add<unsigned int> + 0 (atomic:1061) [inlined]
1   WebCore                       	       0x115aac6b4 fetch_add + 0 (atomic:1748) [inlined]
2   WebCore                       	       0x115aac6b4 operator++ + 0 (atomic:1785) [inlined]
3   WebCore                       	       0x115aac6b4 ref + 0 (ThreadSafeRefCounted.h:60) [inlined]
4   WebCore                       	       0x115aac6b4 Ref + 8 (Ref.h:67) [inlined]
5   WebCore                       	       0x115aac6b4 Ref + 8 (Ref.h:66) [inlined]
6   WebCore                       	       0x115aac6b4 WebCore::AudioSampleDataSource::AudioSampleDataSource(unsigned long, WTF::LoggerHelper&, unsigned long) + 176 (AudioSampleDataSource.mm:57)
Comment 1 Radar WebKit Bug Importer 2022-04-18 16:49:44 PDT
<rdar://problem/91927019>
Comment 2 Karl Rackler 2022-04-18 17:51:57 PDT
REPRODUCTION STEPS
ToT
run-api-tests --root --debug
Comment 3 Alex Christensen 2022-06-15 15:47:28 PDT
Thread 6 Crashed::  Dispatch queue: MockAudioSharedInternalUnit Capture Queue
0   WebCore                       	       0x111279360 unsigned int std::__1::__cxx_atomic_fetch_add<unsigned int>(std::__1::__cxx_atomic_base_impl<unsigned int>*, unsigned int, std::__1::memory_order) + 0 (atomic:1050) [inlined]
1   WebCore                       	       0x111279360 std::__1::__atomic_base<unsigned int, true>::fetch_add(unsigned int, std::__1::memory_order) + 0 (atomic:1719) [inlined]
2   WebCore                       	       0x111279360 std::__1::__atomic_base<unsigned int, true>::operator++() + 0 (atomic:1756) [inlined]
3   WebCore                       	       0x111279360 WTF::ThreadSafeRefCountedBase::ref() const + 0 (ThreadSafeRefCounted.h:60) [inlined]
4   WebCore                       	       0x111279360 WTF::Ref<WTF::Logger const, WTF::RawPtrTraits<WTF::Logger const> >::Ref(WTF::Logger const&) + 8 (Ref.h:67) [inlined]
5   WebCore                       	       0x111279360 WTF::Ref<WTF::Logger const, WTF::RawPtrTraits<WTF::Logger const> >::Ref(WTF::Logger const&) + 8 (Ref.h:66) [inlined]
6   WebCore                       	       0x111279360 WebCore::AudioSampleDataSource::AudioSampleDataSource(unsigned long, WTF::LoggerHelper&, unsigned long) + 196 (AudioSampleDataSource.mm:57)
7   WebCore                       	       0x111279358 WebCore::AudioSampleDataSource::AudioSampleDataSource(unsigned long, WTF::LoggerHelper&, unsigned long) + 188 (AudioSampleDataSource.mm:57)
8   WebCore                       	       0x111279270 WebCore::AudioSampleDataSource::AudioSampleDataSource(unsigned long, WTF::LoggerHelper&, unsigned long) + 16 (AudioSampleDataSource.mm:60) [inlined]
9   WebCore                       	       0x111279270 WebCore::AudioSampleDataSource::create(unsigned long, WTF::LoggerHelper&, unsigned long) + 64 (AudioSampleDataSource.mm:49)
10  WebCore                       	       0x11169cc5c WebCore::SpeechRecognitionCaptureSourceImpl::updateDataSource(WebCore::CAAudioStreamDescription const&) + 96 (SpeechRecognitionCaptureSourceImpl.cpp:91)
11  WebCore                       	       0x11169d040 WebCore::SpeechRecognitionCaptureSourceImpl::audioSamplesAvailable(WTF::MediaTime const&, WebCore::PlatformAudioData const&, WebCore::AudioStreamDescription const&, unsigned long) + 128 (SpeechRecognitionCaptureSourceImpl.cpp:135)
12  WebCore                       	       0x1122d6f34 WebCore::RealtimeMediaSource::audioSamplesAvailable(WTF::MediaTime const&, WebCore::PlatformAudioData const&, WebCore::AudioStreamDescription const&, unsigned long) + 392 (RealtimeMediaSource.cpp:224)
13  WebCore                       	       0x1122fe14c WebCore::BaseAudioSharedUnit::audioSamplesAvailable(WTF::MediaTime const&, WebCore::PlatformAudioData const&, WebCore::AudioStreamDescription const&, unsigned long) + 60 (BaseAudioSharedUnit.cpp:277) [inlined]
14  WebCore                       	       0x1122fe14c WebCore::CoreAudioSharedUnit::processMicrophoneSamples(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList*) + 568 (CoreAudioSharedUnit.cpp:452)
15  WebCore                       	       0x1115b0d1c WebCore::MockAudioSharedInternalUnit::emitSampleBuffers(unsigned int) + 156 (MockAudioSharedUnit.mm:296) [inlined]
16  WebCore                       	       0x1115b0d1c WebCore::MockAudioSharedInternalUnit::generateSampleBuffers(WTF::MonotonicTime) + 1128 (MockAudioSharedUnit.mm:334)
17  JavaScriptCore                	       0x105a893b0 WTF::Function<void ()>::operator()() const + 16 (Function.h:82) [inlined]
18  JavaScriptCore                	       0x105a893b0 WTF::(anonymous namespace)::DispatchWorkItem::operator()() + 16 (WorkQueueCocoa.cpp:40) [inlined]
19  JavaScriptCore                	       0x105a893b0 void WTF::dispatchWorkItem<WTF::(anonymous namespace)::DispatchWorkItem>(void*) + 32 (WorkQueueCocoa.cpp:48)
20  libdispatch.dylib             	       0x189aca1c8 _dispatch_client_callout + 20
21  libdispatch.dylib             	       0x189ad18a8 _dispatch_lane_serial_drain + 668
22  libdispatch.dylib             	       0x189ad2404 _dispatch_lane_invoke + 392
23  libdispatch.dylib             	       0x189adcc98 _dispatch_workloop_worker_thread + 648
24  libsystem_pthread.dylib       	       0x189c8a360 _pthread_wqthread + 288
25  libsystem_pthread.dylib       	       0x189c89080 start_wqthread + 8
Comment 4 Alex Christensen 2022-06-15 16:45:49 PDT
Created attachment 460263 [details]
Patch
Comment 5 Sihui Liu 2022-06-15 17:29:58 PDT
Comment on attachment 460263 [details]
Patch

r=me, thanks for fixing!
Comment 6 EWS 2022-06-16 00:20:57 PDT
Committed r295588 (251593@main): <https://commits.webkit.org/251593@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 460263 [details].