Potentially non thread-safe usage of WebCore::MediaSample
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 02:20:54 +0000 (02:20 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 02:20:54 +0000 (02:20 +0000)
commit1b3bb770d481aea08bb6413970f1004a36070e26
tree9aa37a2c009c557f35ae7c7dc1b01c574dbec3cb
parent64882ac414ca15bb3ccf4814aee7c1024a631ae6
Potentially non thread-safe usage of WebCore::MediaSample
https://bugs.webkit.org/show_bug.cgi?id=200734

Reviewed by Eric Carlson.

ImageSource is a main thread object but ends up getting passed to a background queue for image
decoding. In some cases, the background queue ends up being the last one holding a ref to the
ImageSource which ends up destroying the ImageSource on a background thread. Doing so is not
safe as shown by the crash.

To address the issue, have ImageSource subclass ThreadSafeRefCounted<ImageSource, WTF::DestructionThread::Main>
so that it is always destroyed on the main thread.

No new tests, currently crashing on the debug bots.

* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::ImageSource):
(WebCore::ImageSource::~ImageSource):
* platform/graphics/ImageSource.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ImageSource.cpp
Source/WebCore/platform/graphics/ImageSource.h