[WinCairo] Crash when closing window while video is loading
authorpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Mar 2015 23:01:51 +0000 (23:01 +0000)
committerpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Mar 2015 23:01:51 +0000 (23:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143088

Reviewed by Mark Lam.

When the media player is destroyed, we have to cancel possible calls on the
main thread made by a worker thread. Otherwise the destroyed media player
will be accessed when performing the call.

* platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
(WebCore::MediaPlayerPrivateMediaFoundation::~MediaPlayerPrivateMediaFoundation):
(WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource):
(WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent):
(WebCore::MediaPlayerPrivateMediaFoundation::onTopologySet):
(WebCore::MediaPlayerPrivateMediaFoundation::onCreatedMediaSourceCallback):
(WebCore::MediaPlayerPrivateMediaFoundation::onTopologySetCallback):
* platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182160 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h

index d85357a..7a5d0c4 100644 (file)
@@ -1,3 +1,23 @@
+2015-03-30  Per Arne Vollan  <peavo@outlook.com>
+
+        [WinCairo] Crash when closing window while video is loading
+        https://bugs.webkit.org/show_bug.cgi?id=143088
+
+        Reviewed by Mark Lam.
+
+        When the media player is destroyed, we have to cancel possible calls on the
+        main thread made by a worker thread. Otherwise the destroyed media player
+        will be accessed when performing the call.
+
+        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
+        (WebCore::MediaPlayerPrivateMediaFoundation::~MediaPlayerPrivateMediaFoundation):
+        (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource):
+        (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent):
+        (WebCore::MediaPlayerPrivateMediaFoundation::onTopologySet):
+        (WebCore::MediaPlayerPrivateMediaFoundation::onCreatedMediaSourceCallback):
+        (WebCore::MediaPlayerPrivateMediaFoundation::onTopologySetCallback):
+        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:
+
 2015-03-30  Gwang Yoon Hwang  <yoon@igalia.com>
 
         [Threaded Compositor] Crash when animation changes frequently.
index 0bfb4af..63e7c58 100644 (file)
@@ -78,6 +78,8 @@ MediaPlayerPrivateMediaFoundation::~MediaPlayerPrivateMediaFoundation()
     notifyDeleted();
     destroyVideoWindow();
     endSession();
+    cancelCallOnMainThread(onTopologySetCallback, this);
+    cancelCallOnMainThread(onCreatedMediaSourceCallback, this);
 }
 
 void MediaPlayerPrivateMediaFoundation::registerMediaEngine(MediaEngineRegistrar registrar)
@@ -340,9 +342,7 @@ bool MediaPlayerPrivateMediaFoundation::endCreatedMediaSource(IMFAsyncResult* as
     hr = asyncResult->GetStatus();
     m_loadingProgress = SUCCEEDED(hr);
 
-    callOnMainThread([this] {
-        onCreatedMediaSource();
-    });
+    callOnMainThread(onCreatedMediaSourceCallback, this);
 
     return true;
 }
@@ -367,9 +367,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult)
 
     switch (mediaEventType) {
     case MESessionTopologySet:
-        callOnMainThread([this] {
-            onTopologySet();
-        });
+        callOnMainThread(onTopologySetCallback, this);
         break;
 
     case MESessionClosed:
@@ -645,6 +643,18 @@ void MediaPlayerPrivateMediaFoundation::onTopologySet()
     m_player->playbackStateChanged();
 }
 
+void MediaPlayerPrivateMediaFoundation::onCreatedMediaSourceCallback(void* context)
+{
+    MediaPlayerPrivateMediaFoundation* mediaPlayer = static_cast<MediaPlayerPrivateMediaFoundation*>(context);
+    mediaPlayer->onCreatedMediaSource();
+}
+
+void MediaPlayerPrivateMediaFoundation::onTopologySetCallback(void* context)
+{
+    MediaPlayerPrivateMediaFoundation* mediaPlayer = static_cast<MediaPlayerPrivateMediaFoundation*>(context);
+    mediaPlayer->onTopologySet();
+}
+
 MediaPlayerPrivateMediaFoundation::AsyncCallback::AsyncCallback(MediaPlayerPrivateMediaFoundation* mediaPlayer, bool event)
     : m_refCount(0)
     , m_mediaPlayer(mediaPlayer)
index 13736ae..729d630 100644 (file)
@@ -110,6 +110,8 @@ private:
 
     void onCreatedMediaSource();
     void onTopologySet();
+    static void onCreatedMediaSourceCallback(void* context);
+    static void onTopologySetCallback(void* context);
 
     LPCWSTR registerVideoWindowClass();
     void createVideoWindow();