[webkit-changes] [WebKit/WebKit] 0a505c: [WK1] iOS WK1 application crashes after loading media

Jean-Yves Avenard noreply at github.com
Thu May 30 12:14:44 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0a505cbe327dcfe2c7efe4897bf07ac3532b54fb
      https://github.com/WebKit/WebKit/commit/0a505cbe327dcfe2c7efe4897bf07ac3532b54fb
  Author: Jean-Yves Avenard <jya at apple.com>
  Date:   2024-05-30 (Thu, 30 May 2024)

  Changed paths:
    M Source/WTF/WTF.xcodeproj/project.pbxproj
    M Source/WTF/wtf/CMakeLists.txt
    M Source/WTF/wtf/Forward.h
    A Source/WTF/wtf/MainThreadDispatcher.cpp
    A Source/WTF/wtf/MainThreadDispatcher.h
    M Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h
    M Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
    M Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
    M Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h
    M Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm
    M Source/WebCore/platform/network/cocoa/RangeResponseGenerator.h
    M Source/WebCore/platform/network/cocoa/RangeResponseGenerator.mm
    M Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h
    M Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm
    M Source/WebKit/GPUProcess/media/RemoteMediaResourceLoader.h

  Log Message:
  -----------
  [WK1] iOS WK1 application crashes after loading media
https://bugs.webkit.org/show_bug.cgi?id=274888
rdar://128549043

Reviewed by Youenn Fablet.

In 273804 at main we added the possibility to perform the media networking operation off the main thread.
The PlatformResourceMediaLoader was made to take a WorkQueue on which the operations were to be performed.
For builds without a GPU process or WK1, we used the WorkQueue::main().
However WorkQueue::main() isn't handling the subtelties related to the Web thread vs UI thread.
This triggered a RELEASE_ASSERT(isMainThread()) as isMainThread() with WK1 on iOS checks that we are
on the WebThread.

So instead rather than using WorkQueues we use RefCountedSerialFunctionDispatcher and we introduce
MainThreadDispatcher which is a RCSerialFunctionDispatcher that will dispatch using runOnMainThread().

Covered by existing tests.

* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/CMakeLists.txt:
* Source/WTF/wtf/Forward.h:
* Source/WTF/wtf/MainThreadDispatcher.cpp: Added.
(WTF::MainThreadDispatcher::singleton):
(WTF::MainThreadDispatcher::isCurrent const):
(WTF::MainThreadDispatcher::dispatch):
(WTF::MainThreadDispatcher::ref const):
(WTF::MainThreadDispatcher::deref const):
* Source/WTF/wtf/MainThreadDispatcher.h: Added.
* Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h:
(WebCore::PlatformMediaResourceLoader::targetDispatcher):
(WebCore::PlatformMediaResourceLoader::targetQueue): Deleted.
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
(WebCore::MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest):
(WebCore::MediaPlayerPrivateAVFoundationObjC::didStopLoadingRequest):
* Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h:
* Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::PlatformResourceMediaLoader::PlatformResourceMediaLoader):
(WebCore::PlatformResourceMediaLoader::stop):
(WebCore::PlatformResourceMediaLoader::responseReceived):
(WebCore::PlatformResourceMediaLoader::loadFailed):
(WebCore::PlatformResourceMediaLoader::loadFinished):
(WebCore::PlatformResourceMediaLoader::dataReceived):
(WebCore::DataURLResourceMediaLoader::DataURLResourceMediaLoader):
(WebCore::WebCoreAVFResourceLoader::create):
(WebCore::WebCoreAVFResourceLoader::WebCoreAVFResourceLoader):
(WebCore::WebCoreAVFResourceLoader::stopLoading):
(WebCore::WebCoreAVFResourceLoader::responseReceived):
(WebCore::WebCoreAVFResourceLoader::loadFailed):
(WebCore::WebCoreAVFResourceLoader::loadFinished):
(WebCore::WebCoreAVFResourceLoader::newDataStoredInSharedBuffer):
* Source/WebCore/platform/network/cocoa/RangeResponseGenerator.h:
* Source/WebCore/platform/network/cocoa/RangeResponseGenerator.mm:
(WebCore::RangeResponseGenerator::RangeResponseGenerator):
(WebCore::RangeResponseGenerator::map):
(WebCore::RangeResponseGenerator::giveResponseToTaskIfBytesInRangeReceived):
(WebCore::RangeResponseGenerator::giveResponseToTasksWithFinishedRanges):
(WebCore::RangeResponseGenerator::willHandleRequest):
(WebCore::RangeResponseGenerator::willSynthesizeRangeResponses):
* Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h:
* Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSessionTaskTransactionMetrics _initWithMetrics:onTarget:]):
(-[WebCoreNSURLSessionTaskTransactionMetrics dealloc]):
(-[WebCoreNSURLSessionTaskMetrics _initWithMetrics:onTarget:]):
(-[WebCoreNSURLSessionTaskMetrics dealloc]):
(-[WebCoreNSURLSession initWithResourceLoader:delegate:delegateQueue:]):
(-[WebCoreNSURLSession dealloc]):
(-[WebCoreNSURLSession taskCompleted:]):
(-[WebCoreNSURLSession task:didReceiveCORSAccessCheckResult:]):
(-[WebCoreNSURLSession task:addSecurityOrigin:]):
(-[WebCoreNSURLSession rangeResponseGenerator]):
(-[WebCoreNSURLSession dataTaskWithRequest:]):
(WebCore::WebCoreNSURLSessionDataTaskClient::WebCoreNSURLSessionDataTaskClient):
(WebCore::WebCoreNSURLSessionDataTaskClient::clearTask):
(WebCore::WebCoreNSURLSessionDataTaskClient::dataSent):
(WebCore::WebCoreNSURLSessionDataTaskClient::responseReceived):
(WebCore::WebCoreNSURLSessionDataTaskClient::shouldCacheResponse):
(WebCore::WebCoreNSURLSessionDataTaskClient::dataReceived):
(WebCore::WebCoreNSURLSessionDataTaskClient::redirectReceived):
(WebCore::WebCoreNSURLSessionDataTaskClient::accessControlCheckFailed):
(WebCore::WebCoreNSURLSessionDataTaskClient::loadFailed):
(WebCore::WebCoreNSURLSessionDataTaskClient::loadFinished):
(-[WebCoreNSURLSessionDataTask initWithSession:identifier:request:targetDispatcher:]):
(-[WebCoreNSURLSessionDataTask _cancel]):
(-[WebCoreNSURLSessionDataTask resource]):
(-[WebCoreNSURLSessionDataTask setResource:]):
(-[WebCoreNSURLSessionDataTask cancel]):
(-[WebCoreNSURLSessionDataTask suspend]):
(-[WebCoreNSURLSessionDataTask resume]):
(-[WebCoreNSURLSessionDataTask dealloc]):
(-[WebCoreNSURLSessionDataTask resource:sentBytes:totalBytesToBeSent:]):
(-[WebCoreNSURLSessionDataTask resource:receivedResponse:completionHandler:]):
(-[WebCoreNSURLSessionDataTask resource:shouldCacheResponse:]):
(-[WebCoreNSURLSessionDataTask resource:receivedData:]):
(-[WebCoreNSURLSessionDataTask resource:receivedRedirect:request:completionHandler:]):
(-[WebCoreNSURLSessionDataTask _resource:loadFinishedWithError:metrics:]):
(-[WebCoreNSURLSessionDataTask resource:accessControlCheckFailedWithError:]):
(-[WebCoreNSURLSessionDataTask resource:loadFailedWithError:]):
(-[WebCoreNSURLSessionDataTask resourceFinished:metrics:]):
(-[WebCoreNSURLSessionDataTask initWithSession:identifier:request:targetQueue:]): Deleted.
* Source/WebKit/GPUProcess/media/RemoteMediaResourceLoader.h:

Canonical link: https://commits.webkit.org/279535@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list