Changeset 254291 in webkit


Ignore:
Timestamp:
Jan 9, 2020 12:52:33 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

ImageBitmap can't be created in workers in some cases due to main-thread assert in ImageSource
https://bugs.webkit.org/show_bug.cgi?id=205850

Patch by Chris Lord <Chris Lord> on 2020-01-09
Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

  • web-platform-tests/2dcontext/imagebitmap/createImageBitmap-in-worker-transfer-expected.txt: Added.
  • web-platform-tests/2dcontext/imagebitmap/createImageBitmap-in-worker-transfer.html: Added.
  • web-platform-tests/2dcontext/imagebitmap/createImageBitmap-worker.js: Added.

Source/WebCore:

Assert that we're destroyed on the creation thread, rather than on the
main thread. This is required for ImageBitmap creation in workers in
debug builds.

Test: imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-in-worker-transfer.html

  • platform/graphics/ImageSource.cpp:

(WebCore::ImageSource::ImageSource):
(WebCore::ImageSource::~ImageSource):
(WebCore::ImageSource::startAsyncDecodingQueue):

  • platform/graphics/ImageSource.h:
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r254285 r254291  
     12020-01-09  Chris Lord  <clord@igalia.com>
     2
     3        ImageBitmap can't be created in workers in some cases due to main-thread assert in ImageSource
     4        https://bugs.webkit.org/show_bug.cgi?id=205850
     5
     6        Reviewed by Dean Jackson.
     7
     8        * web-platform-tests/2dcontext/imagebitmap/createImageBitmap-in-worker-transfer-expected.txt: Added.
     9        * web-platform-tests/2dcontext/imagebitmap/createImageBitmap-in-worker-transfer.html: Added.
     10        * web-platform-tests/2dcontext/imagebitmap/createImageBitmap-worker.js: Added.
     11
    1122020-01-09  Pablo Saavedra  <psaavedra@igalia.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r254288 r254291  
     12020-01-09  Chris Lord  <clord@igalia.com>
     2
     3        ImageBitmap can't be created in workers in some cases due to main-thread assert in ImageSource
     4        https://bugs.webkit.org/show_bug.cgi?id=205850
     5
     6        Reviewed by Dean Jackson.
     7
     8        Assert that we're destroyed on the creation thread, rather than on the
     9        main thread. This is required for ImageBitmap creation in workers in
     10        debug builds.
     11
     12        Test: imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-in-worker-transfer.html
     13
     14        * platform/graphics/ImageSource.cpp:
     15        (WebCore::ImageSource::ImageSource):
     16        (WebCore::ImageSource::~ImageSource):
     17        (WebCore::ImageSource::startAsyncDecodingQueue):
     18        * platform/graphics/ImageSource.h:
     19
    1202020-01-09  Jer Noble  <jer.noble@apple.com>
    221
  • trunk/Source/WebCore/platform/graphics/ImageSource.cpp

    r249364 r254291  
    3232#include "Logging.h"
    3333#include <wtf/CheckedArithmetic.h>
    34 #include <wtf/MainThread.h>
    35 #include <wtf/RunLoop.h>
    3634#include <wtf/SystemTracing.h>
    3735#include <wtf/URL.h>
     
    4846    , m_alphaOption(alphaOption)
    4947    , m_gammaAndColorProfileOption(gammaAndColorProfileOption)
    50 {
    51     ASSERT(isMainThread());
     48    , m_runLoop(RunLoop::current())
     49{
    5250}
    5351
    5452ImageSource::ImageSource(NativeImagePtr&& nativeImage)
    55 {
    56     ASSERT(isMainThread());
    57 
     53    : m_runLoop(RunLoop::current())
     54{
    5855    m_frameCount = 1;
    5956    m_encodedDataStatus = EncodedDataStatus::Complete;
     
    7168{
    7269    ASSERT(!hasAsyncDecodingQueue());
    73     ASSERT(isMainThread());
     70    ASSERT(&m_runLoop == &RunLoop::current());
    7471}
    7572
     
    374371                sleep(minDecodingDuration - (MonotonicTime::now() - startingTime));
    375372
    376             // Update the cached frames on the main thread to avoid updating the MemoryCache from a different thread.
    377             callOnMainThread([protectedThis = protectedThis.copyRef(), protectedQueue = protectedDecodingQueue.copyRef(), protectedDecoder = protectedDecoder.copyRef(), sourceURL = sourceURL.isolatedCopy(), nativeImage = WTFMove(nativeImage), frameRequest] () mutable {
     373            // Update the cached frames on the creation thread to avoid updating the MemoryCache from a different thread.
     374            protectedThis->m_runLoop.dispatch([protectedThis = protectedThis.copyRef(), protectedQueue = protectedDecodingQueue.copyRef(), protectedDecoder = protectedDecoder.copyRef(), sourceURL = sourceURL.isolatedCopy(), nativeImage = WTFMove(nativeImage), frameRequest] () mutable {
    378375                // The queue may have been closed if after we got the frame NativeImage, stopAsyncDecodingQueue() was called.
    379376                if (protectedQueue.ptr() == protectedThis->m_decodingQueue && protectedDecoder.ptr() == protectedThis->m_decoder) {
  • trunk/Source/WebCore/platform/graphics/ImageSource.h

    r249364 r254291  
    3030#include <wtf/Forward.h>
    3131#include <wtf/Optional.h>
     32#include <wtf/RunLoop.h>
    3233#include <wtf/SynchronizedFixedQueue.h>
    3334#include <wtf/WeakPtr.h>
     
    4142class ImageDecoder;
    4243
    43 class ImageSource : public ThreadSafeRefCounted<ImageSource, WTF::DestructionThread::Main>, public CanMakeWeakPtr<ImageSource> {
     44class ImageSource : public ThreadSafeRefCounted<ImageSource>, public CanMakeWeakPtr<ImageSource> {
    4445    friend class BitmapImage;
    4546public:
     
    201202    Optional<Color> m_singlePixelSolidColor;
    202203    Optional<SubsamplingLevel> m_maximumSubsamplingLevel;
     204
     205    RunLoop& m_runLoop;
    203206};
    204207
Note: See TracChangeset for help on using the changeset viewer.