Changeset 247380 in webkit
- Timestamp:
- Jul 11, 2019 7:35:07 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247379 r247380 1 2019-07-11 Chris Dumez <cdumez@apple.com> 2 3 Drop non thread-safe usage of WeakPtr in PlaybackSessionInterfaceAVKit 4 https://bugs.webkit.org/show_bug.cgi?id=199698 5 6 Reviewed by Eric Carlson. 7 8 The PlaybackSessionInterfaceAVKit constructor was making a weakPtr on the UI Thread 9 of an WebThread object. The WeakPtr would then be used as a data member throughout 10 the class on the UIThread. This is not thread-safe. 11 12 This patch switches to using a raw pointer instead of a WeakPtr. This is a partial 13 rollout of r243337, which turned the raw pointer into a WeakPtr for hardening 14 purposes. For extra safety, this patch updates the VideoFullscreenControllerContext 15 so that it notifies its clients (i.e. PlaybackSessionInterfaceAVKit) that it is 16 getting destroyed, so that they can null-out their m_playbackSessionModel data 17 member. This gives the sames guarantees than WeakPtr but in a thread-safe way. 18 19 * platform/cocoa/PlaybackSessionModel.h: 20 (WebCore::PlaybackSessionModelClient::modelDestroyed): 21 * platform/ios/PlaybackSessionInterfaceAVKit.h: 22 * platform/ios/PlaybackSessionInterfaceAVKit.mm: 23 (WebCore::PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit): 24 (WebCore::PlaybackSessionInterfaceAVKit::~PlaybackSessionInterfaceAVKit): 25 (WebCore::PlaybackSessionInterfaceAVKit::playbackSessionModel const): 26 (WebCore::PlaybackSessionInterfaceAVKit::modelDestroyed): 27 * platform/ios/WebVideoFullscreenControllerAVKit.mm: 28 (VideoFullscreenControllerContext::~VideoFullscreenControllerContext): 29 (VideoFullscreenControllerContext::addClient): 30 (VideoFullscreenControllerContext::removeClient): 31 1 32 2019-07-11 Simon Fraser <simon.fraser@apple.com> 2 33 -
trunk/Source/WebCore/platform/cocoa/PlaybackSessionModel.h
r243337 r247380 111 111 virtual void pictureInPictureActiveChanged(bool) { } 112 112 virtual void ensureControlsManager() { } 113 virtual void modelDestroyed() { } 113 114 }; 114 115 -
trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h
r243337 r247380 78 78 WEBCORE_EXPORT void mutedChanged(bool) override; 79 79 WEBCORE_EXPORT void volumeChanged(double) override; 80 WEBCORE_EXPORT void modelDestroyed() override; 80 81 81 82 WEBCORE_EXPORT virtual void invalidate(); … … 87 88 88 89 RetainPtr<WebAVPlayerController> m_playerController; 89 WeakPtr<PlaybackSessionModel> m_playbackSessionModel;90 PlaybackSessionModel* m_playbackSessionModel { nullptr }; 90 91 }; 91 92 -
trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm
r243338 r247380 52 52 PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit(PlaybackSessionModel& model) 53 53 : m_playerController(adoptNS([[WebAVPlayerController alloc] init])) 54 , m_playbackSessionModel(makeWeakPtr(model)) 55 { 54 , m_playbackSessionModel(&model) 55 { 56 ASSERT(isUIThread()); 56 57 model.addClient(*this); 57 58 [m_playerController setPlaybackSessionInterface:this]; … … 72 73 PlaybackSessionInterfaceAVKit::~PlaybackSessionInterfaceAVKit() 73 74 { 75 ASSERT(isUIThread()); 74 76 [m_playerController setPlaybackSessionInterface:nullptr]; 75 77 [m_playerController setExternalPlaybackActive:false]; … … 80 82 PlaybackSessionModel* PlaybackSessionInterfaceAVKit::playbackSessionModel() const 81 83 { 82 return m_playbackSessionModel .get();84 return m_playbackSessionModel; 83 85 } 84 86 … … 220 222 } 221 223 224 void PlaybackSessionInterfaceAVKit::modelDestroyed() 225 { 226 ASSERT(isUIThread()); 227 invalidate(); 228 ASSERT(!m_playbackSessionModel); 229 } 230 222 231 } 223 232 -
trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
r240355 r247380 109 109 return adoptRef(*new VideoFullscreenControllerContext); 110 110 } 111 112 ~VideoFullscreenControllerContext(); 111 113 112 114 void setController(WebVideoFullscreenController* controller) { m_controller = controller; } … … 217 219 }; 218 220 221 VideoFullscreenControllerContext::~VideoFullscreenControllerContext() 222 { 223 auto notifyClientsModelWasDestroyed = [this] { 224 while (!m_playbackClients.isEmpty()) 225 (*m_playbackClients.begin())->modelDestroyed(); 226 }; 227 if (isUIThread()) 228 notifyClientsModelWasDestroyed(); 229 else 230 dispatch_sync(dispatch_get_main_queue(), WTFMove(notifyClientsModelWasDestroyed)); 231 } 232 219 233 #pragma mark VideoFullscreenChangeObserver 220 234 … … 544 558 void VideoFullscreenControllerContext::addClient(VideoFullscreenModelClient& client) 545 559 { 560 ASSERT(isUIThread()); 546 561 ASSERT(!m_fullscreenClients.contains(&client)); 547 562 m_fullscreenClients.add(&client); … … 550 565 void VideoFullscreenControllerContext::removeClient(VideoFullscreenModelClient& client) 551 566 { 567 ASSERT(isUIThread()); 552 568 ASSERT(m_fullscreenClients.contains(&client)); 553 569 m_fullscreenClients.remove(&client);
Note: See TracChangeset
for help on using the changeset viewer.