Title: [281132] trunk/Source/WebCore
- Revision
- 281132
- Author
- jer.no...@apple.com
- Date
- 2021-08-17 00:22:16 -0700 (Tue, 17 Aug 2021)
Log Message
LayoutTests imported/w3c/web-platform-tests/html/canvas/element/imagebitmap/createImageBitmap-* are flakey
https://bugs.webkit.org/show_bug.cgi?id=229169
Reviewed by Eric Carlson.
When a data:// URL is passed to AVFoundation, the loading of that URL is handled by WebCoreAVFResourceLoader,
which in turn relies on a PlatformMediaResourceLoader to turn the data URL into a data buffer. However, in the
case of the GPU process, this means dispatching the request from GPU, to WebContent, to Network process and to
send the data back from the Network, to WebContent, to GPU process. If a synchronous operation (like painting)
is underway, the data response can block until that synchronous operation completes. If that operation is a
paint, and the data requested is required to complete that paint, the paint will fail.
For the narrow case of a data:// URL, it's not necessary to dispatch to another process to turn that URL into
data; it can happen locally, avoiding the hop to another process and the subsequent deadlock.
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h:
(WebCore::WebCoreAVFResourceLoader::logger const):
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::DataURLResourceMediaLoader::DataURLResourceMediaLoader):
(WebCore::WebCoreAVFResourceLoader::~WebCoreAVFResourceLoader):
(WebCore::WebCoreAVFResourceLoader::startLoading):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (281131 => 281132)
--- trunk/Source/WebCore/ChangeLog 2021-08-17 06:59:30 UTC (rev 281131)
+++ trunk/Source/WebCore/ChangeLog 2021-08-17 07:22:16 UTC (rev 281132)
@@ -1,3 +1,27 @@
+2021-08-17 Jer Noble <jer.no...@apple.com>
+
+ LayoutTests imported/w3c/web-platform-tests/html/canvas/element/imagebitmap/createImageBitmap-* are flakey
+ https://bugs.webkit.org/show_bug.cgi?id=229169
+
+ Reviewed by Eric Carlson.
+
+ When a data:// URL is passed to AVFoundation, the loading of that URL is handled by WebCoreAVFResourceLoader,
+ which in turn relies on a PlatformMediaResourceLoader to turn the data URL into a data buffer. However, in the
+ case of the GPU process, this means dispatching the request from GPU, to WebContent, to Network process and to
+ send the data back from the Network, to WebContent, to GPU process. If a synchronous operation (like painting)
+ is underway, the data response can block until that synchronous operation completes. If that operation is a
+ paint, and the data requested is required to complete that paint, the paint will fail.
+
+ For the narrow case of a data:// URL, it's not necessary to dispatch to another process to turn that URL into
+ data; it can happen locally, avoiding the hop to another process and the subsequent deadlock.
+
+ * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h:
+ (WebCore::WebCoreAVFResourceLoader::logger const):
+ * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
+ (WebCore::DataURLResourceMediaLoader::DataURLResourceMediaLoader):
+ (WebCore::WebCoreAVFResourceLoader::~WebCoreAVFResourceLoader):
+ (WebCore::WebCoreAVFResourceLoader::startLoading):
+
2021-08-16 Antti Koivisto <an...@apple.com>
REGRESSION (r275756): Accelerated animations freeze when invalidating layout with shadow dom
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h (281131 => 281132)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h 2021-08-17 06:59:30 UTC (rev 281131)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h 2021-08-17 07:22:16 UTC (rev 281132)
@@ -38,6 +38,7 @@
namespace WebCore {
class CachedResourceMediaLoader;
+class DataURLResourceMediaLoader;
class MediaPlayerPrivateAVFoundationObjC;
class PlatformResourceMediaLoader;
class ResourceError;
@@ -58,6 +59,7 @@
WebCoreAVFResourceLoader(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest *);
friend class CachedResourceMediaLoader;
+ friend class DataURLResourceMediaLoader;
friend class PlatformResourceMediaLoader;
void responseReceived(const ResourceResponse&);
@@ -67,6 +69,7 @@
MediaPlayerPrivateAVFoundationObjC* m_parent;
RetainPtr<AVAssetResourceLoadingRequest> m_avRequest;
+ std::unique_ptr<DataURLResourceMediaLoader> m_dataURLMediaLoader;
std::unique_ptr<CachedResourceMediaLoader> m_resourceMediaLoader;
WeakPtr<PlatformResourceMediaLoader> m_platformMediaLoader;
size_t m_responseOffset { 0 };
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (281131 => 281132)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm 2021-08-17 06:59:30 UTC (rev 281131)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm 2021-08-17 07:22:16 UTC (rev 281132)
@@ -218,6 +218,50 @@
m_parent.newDataStoredInSharedBuffer(*m_buffer);
}
+class DataURLResourceMediaLoader : public CanMakeWeakPtr<DataURLResourceMediaLoader> {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ DataURLResourceMediaLoader(WebCoreAVFResourceLoader&, ResourceRequest&&);
+
+private:
+ WebCoreAVFResourceLoader& m_parent;
+ std::unique_ptr<ResourceResponse> m_response;
+ RefPtr<SharedBuffer> m_buffer;
+};
+
+DataURLResourceMediaLoader::DataURLResourceMediaLoader(WebCoreAVFResourceLoader& parent, ResourceRequest&& request)
+ : m_parent(parent)
+{
+ ASSERT(request.url().protocolIsData());
+
+ if (request.url().protocolIsData()) {
+ auto mimeType = mimeTypeFromDataURL(request.url().string());
+ auto nsData = adoptNS([[NSData alloc] initWithContentsOfURL:request.url()]);
+ ASSERT(nsData);
+ m_buffer = SharedBuffer::create(nsData.get());
+ m_response = WTF::makeUnique<ResourceResponse>(request.url(), mimeType, m_buffer->size(), emptyString());
+ }
+
+ callOnMainThread([this, weakThis = makeWeakPtr(*this)] {
+ if (!weakThis)
+ return;
+
+ if (!m_buffer || !m_response) {
+ m_parent.loadFailed(ResourceError(ResourceError::Type::General));
+ return;
+ }
+ m_parent.responseReceived(*m_response);
+ if (!weakThis)
+ return;
+
+ m_parent.newDataStoredInSharedBuffer(*m_buffer);
+ if (!weakThis)
+ return;
+
+ m_parent.loadFinished();
+ });
+}
+
Ref<WebCoreAVFResourceLoader> WebCoreAVFResourceLoader::create(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest *avRequest)
{
ASSERT(avRequest);
@@ -238,7 +282,7 @@
void WebCoreAVFResourceLoader::startLoading()
{
- if (m_resourceMediaLoader || m_platformMediaLoader || !m_parent)
+ if (m_dataURLMediaLoader || m_resourceMediaLoader || m_platformMediaLoader || !m_parent)
return;
NSURLRequest *nsRequest = [m_avRequest.get() request];
@@ -253,6 +297,11 @@
request.addHTTPHeaderField(HTTPHeaderName::Range, makeString("bytes=", dataRequest.requestedOffset, '-', rangeEnd));
}
+ if (request.url().protocolIsData()) {
+ m_dataURLMediaLoader = WTF::makeUnique<DataURLResourceMediaLoader>(*this, WTFMove(request));
+ return;
+ }
+
if (auto* loader = m_parent->player()->cachedResourceLoader()) {
m_resourceMediaLoader = CachedResourceMediaLoader::create(*this, *loader, ResourceRequest(request));
if (m_resourceMediaLoader)
@@ -271,6 +320,7 @@
void WebCoreAVFResourceLoader::stopLoading()
{
+ m_dataURLMediaLoader = nullptr;
m_resourceMediaLoader = nullptr;
if (m_platformMediaLoader) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes