+2013-09-23 Brent Fulgham <bfulgham@apple.com>
+
+ [Windows] Moving back in history from a page with <video>, then moving forward causes crash.
+ https://bugs.webkit.org/show_bug.cgi?id=120475
+
+ Reviewed by Anders Carlsson.
+
+ * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+ (WebCore::AVFWrapper::AVFWrapper): Add assertion that creation is on main thread.
+ (WebCore::AVFWrapper::~AVFWrapper): Add assertion that destruction is on main thread.
+ (WebCore::destroyAVFWrapper): Helper function to dispatch on main queue.
+ (WebCore::AVFWrapper::disconnectAndDeleteAVFWrapper): Spawn AVFoundationCF destruction to
+ main queue.
+
2013-09-23 Andreas Kling <akling@apple.com>
RenderTextControlSingleLine::updateFromElement() override not needed.
, m_objectID(s_nextAVFWrapperObjectID++)
, m_currentTrack(0)
{
+ ASSERT(isMainThread());
LOG(Media, "AVFWrapper::AVFWrapper(%p)", this);
m_notificationQueue = dispatch_queue_create("MediaPlayerPrivateAVFoundationCF.notificationQueue", 0);
AVFWrapper::~AVFWrapper()
{
+ ASSERT(isMainThread());
LOG(Media, "AVFWrapper::~AVFWrapper(%p %d)", this, m_objectID);
destroyVideoLayer();
dispatch_async_f(dispatchQueue(), this, disconnectAndDeleteAVFWrapper);
}
+static void destroyAVFWrapper(void* context)
+{
+ AVFWrapper* avfWrapper = static_cast<AVFWrapper*>(context);
+ if (!avfWrapper)
+ return;
+
+ delete avfWrapper;
+}
+
void AVFWrapper::disconnectAndDeleteAVFWrapper(void* context)
{
AVFWrapper* avfWrapper = static_cast<AVFWrapper*>(context);
AVCFPlayerItemRemoveOutput(avfWrapper->avPlayerItem(), avfWrapper->legibleOutput());
#endif
- delete avfWrapper;
+ // We must release the AVCFPlayer and other items on the same thread that created them.
+ dispatch_async_f(dispatch_get_main_queue(), context, destroyAVFWrapper);
}
void AVFWrapper::createAssetForURL(const String& url)