Title: [162685] trunk/Source/WebCore
Revision
162685
Author
jer.no...@apple.com
Date
2014-01-23 20:59:15 -0800 (Thu, 23 Jan 2014)

Log Message

[MSE][Mac] Crash when reloading a page during playback
https://bugs.webkit.org/show_bug.cgi?id=126903

Reviewed by Eric Carlson.

Periodic time observers added to AVSampleBufferRenderSynchronizer will execute their
callback block even after being removed with -removeTimeObserver:, which is tracked by
<rdar://problem/15798050>. Work around this problem by passing a WeakPtr into the block
and bail early if the owning media player has been destroyed.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (162684 => 162685)


--- trunk/Source/WebCore/ChangeLog	2014-01-24 04:51:06 UTC (rev 162684)
+++ trunk/Source/WebCore/ChangeLog	2014-01-24 04:59:15 UTC (rev 162685)
@@ -1,3 +1,20 @@
+2014-01-23  Jer Noble  <jer.no...@apple.com>
+
+        [MSE][Mac] Crash when reloading a page during playback
+        https://bugs.webkit.org/show_bug.cgi?id=126903
+
+        Reviewed by Eric Carlson.
+
+        Periodic time observers added to AVSampleBufferRenderSynchronizer will execute their
+        callback block even after being removed with -removeTimeObserver:, which is tracked by
+        <rdar://problem/15798050>. Work around this problem by passing a WeakPtr into the block
+        and bail early if the owning media player has been destroyed.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
+
 2014-01-23  ChangSeok Oh  <changseok...@collabora.com>
 
         Dragging from inner side of video to outside causes a crash

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (162684 => 162685)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2014-01-24 04:51:06 UTC (rev 162684)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2014-01-24 04:59:15 UTC (rev 162685)
@@ -32,6 +32,7 @@
 #include "SourceBufferPrivateClient.h"
 #include <wtf/MediaTime.h>
 #include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
 
 OBJC_CLASS AVAsset;
 OBJC_CLASS AVSampleBufferAudioRenderer;
@@ -151,6 +152,8 @@
     void ensureLayer();
     void destroyLayer();
 
+    WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+
     // MediaPlayer Factory Methods
     static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
     static bool isAvailable();
@@ -160,6 +163,7 @@
     friend class MediaSourcePrivateAVFObjC;
 
     MediaPlayer* m_player;
+    WeakPtrFactory<MediaPlayerPrivateMediaSourceAVFObjC> m_weakPtrFactory;
     RefPtr<HTMLMediaSource> m_mediaSource;
     RefPtr<MediaSourcePrivateAVFObjC> m_mediaSourcePrivate;
     RetainPtr<AVAsset> m_asset;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (162684 => 162685)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2014-01-24 04:51:06 UTC (rev 162684)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2014-01-24 04:59:15 UTC (rev 162685)
@@ -123,6 +123,7 @@
 
 MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(MediaPlayer* player)
     : m_player(player)
+    , m_weakPtrFactory(this)
     , m_synchronizer(adoptNS([[getAVSampleBufferRenderSynchronizerClass() alloc] init]))
     , m_networkState(MediaPlayer::Empty)
     , m_readyState(MediaPlayer::HaveNothing)
@@ -137,7 +138,12 @@
 
     // addPeriodicTimeObserverForInterval: throws an exception if you pass a non-numeric CMTime, so just use
     // an arbitrarily large time value of once an hour:
+    __block auto weakThis = createWeakPtr();
     m_timeJumpedObserver = [m_synchronizer addPeriodicTimeObserverForInterval:toCMTime(MediaTime::createWithDouble(3600)) queue:dispatch_get_main_queue() usingBlock:^(CMTime){
+        // FIXME: Remove the below once <rdar://problem/15798050> is fixed.
+        if (!weakThis)
+            return;
+
         if (m_seeking)
             m_seeking = false;
         m_player->timeChanged();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to