RESOLVED FIXED232430
Fix potential race in AudioMediaStreamTrackRendererCocoa::pushSamples
https://bugs.webkit.org/show_bug.cgi?id=232430
Summary Fix potential race in AudioMediaStreamTrackRendererCocoa::pushSamples
youenn fablet
Reported 2021-10-28 03:20:41 PDT
Fix potential race in AudioMediaStreamTrackRendererCocoa::pushSamples
Attachments
Patch (7.15 KB, patch)
2021-10-28 05:25 PDT, youenn fablet
no flags
Patch (7.17 KB, patch)
2021-10-28 05:38 PDT, youenn fablet
no flags
Patch for landing (7.27 KB, patch)
2021-10-29 03:05 PDT, youenn fablet
no flags
youenn fablet
Comment 1 2021-10-28 05:25:43 PDT
youenn fablet
Comment 2 2021-10-28 05:38:00 PDT
Eric Carlson
Comment 3 2021-10-28 08:48:31 PDT
Comment on attachment 442696 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=442696&action=review > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:65 > void AudioMediaStreamTrackRendererCocoa::stop() > { > - if (m_dataSource) > - AudioMediaStreamTrackRendererUnit::singleton().removeSource(*m_dataSource); > + if (m_registeredDataSource) > + AudioMediaStreamTrackRendererUnit::singleton().removeSource(*m_registeredDataSource); Should we assert that this is called on the main thread? > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:80 > + if (m_registeredDataSource) > + m_registeredDataSource->setVolume(volume); Ditto > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:97 > +void AudioMediaStreamTrackRendererCocoa::setRegisteredDataSource(RefPtr<AudioSampleDataSource>&& source) > +{ Ditto > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:106 > + if (!m_outputDescription) > + return; > + > + m_registeredDataSource = WTFMove(source); > + if (!m_registeredDataSource) > + return; Shouldn't the order of these be switched so we always update m_registeredDataSource, and e.g. not set it to NULL when there is no source? > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:108 > +#if !RELEASE_LOG_DISABLED RELEASE_LOG_DISABLED is always defined for PLATFORM(COCOA), so I think this is unnecessary.
youenn fablet
Comment 4 2021-10-29 03:03:27 PDT
(In reply to Eric Carlson from comment #3) > Comment on attachment 442696 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=442696&action=review > > > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:65 > > void AudioMediaStreamTrackRendererCocoa::stop() > > { > > - if (m_dataSource) > > - AudioMediaStreamTrackRendererUnit::singleton().removeSource(*m_dataSource); > > + if (m_registeredDataSource) > > + AudioMediaStreamTrackRendererUnit::singleton().removeSource(*m_registeredDataSource); > > Should we assert that this is called on the main thread? OK > > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:80 > > + if (m_registeredDataSource) > > + m_registeredDataSource->setVolume(volume); > > Ditto OK > > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:97 > > +void AudioMediaStreamTrackRendererCocoa::setRegisteredDataSource(RefPtr<AudioSampleDataSource>&& source) > > +{ > > Ditto OK > > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:106 > > + if (!m_outputDescription) > > + return; > > + > > + m_registeredDataSource = WTFMove(source); > > + if (!m_registeredDataSource) > > + return; > > Shouldn't the order of these be switched so we always update > m_registeredDataSource, and e.g. not set it to NULL when there is no source? I think it is good to set m_registeredDataSource to nullptr so that we unregister it only once for instance. And we tentatively destroy it as soon as we no longer need it. > > Source/WebCore/platform/mediastream/cocoa/AudioMediaStreamTrackRendererCocoa.cpp:108 > > +#if !RELEASE_LOG_DISABLED > > RELEASE_LOG_DISABLED is always defined for PLATFORM(COCOA), so I think this > is unnecessary. OK
youenn fablet
Comment 5 2021-10-29 03:05:20 PDT
Created attachment 442801 [details] Patch for landing
EWS
Comment 6 2021-10-29 03:59:42 PDT
Committed r285024 (243668@main): <https://commits.webkit.org/243668@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 442801 [details].
Radar WebKit Bug Importer
Comment 7 2021-10-29 04:00:25 PDT
Note You need to log in before you can comment on or make changes to this bug.