Title: [282609] trunk/Source/WebCore
Revision
282609
Author
[email protected]
Date
2021-09-16 15:28:57 -0700 (Thu, 16 Sep 2021)

Log Message

ASSERTION FAILED: nsData under DataURLResourceMediaLoader::DataURLResourceMediaLoader()
https://bugs.webkit.org/show_bug.cgi?id=230355
<rdar://82980375>

Reviewed by Eric Carlson.

Port DataURLResourceMediaLoader to use WebKit's DataURLDecoder instead of relying on
NSData to do so. Also, add data url decoding failure handling instead of crashing in
debug with an assertion.

No new tests, covered by existing tests.

* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::DataURLResourceMediaLoader::DataURLResourceMediaLoader):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282608 => 282609)


--- trunk/Source/WebCore/ChangeLog	2021-09-16 22:28:47 UTC (rev 282608)
+++ trunk/Source/WebCore/ChangeLog	2021-09-16 22:28:57 UTC (rev 282609)
@@ -1,5 +1,22 @@
 2021-09-16  Chris Dumez  <[email protected]>
 
+        ASSERTION FAILED: nsData under DataURLResourceMediaLoader::DataURLResourceMediaLoader()
+        https://bugs.webkit.org/show_bug.cgi?id=230355
+        <rdar://82980375>
+
+        Reviewed by Eric Carlson.
+
+        Port DataURLResourceMediaLoader to use WebKit's DataURLDecoder instead of relying on
+        NSData to do so. Also, add data url decoding failure handling instead of crashing in
+        debug with an assertion.
+
+        No new tests, covered by existing tests.
+
+        * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
+        (WebCore::DataURLResourceMediaLoader::DataURLResourceMediaLoader):
+
+2021-09-16  Chris Dumez  <[email protected]>
+
         [ MacOS & iOS ] imported/w3c/web-platform-tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_noopener.html is flaky failing
         https://bugs.webkit.org/show_bug.cgi?id=228089
         <rdar://problem/80801807>

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (282608 => 282609)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm	2021-09-16 22:28:47 UTC (rev 282608)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm	2021-09-16 22:28:57 UTC (rev 282609)
@@ -31,6 +31,7 @@
 #import "CachedRawResource.h"
 #import "CachedResourceLoader.h"
 #import "CachedResourceRequest.h"
+#import "DataURLDecoder.h"
 #import "MediaPlayerPrivateAVFoundationObjC.h"
 #import "ResourceLoaderOptions.h"
 #import "SharedBuffer.h"
@@ -225,7 +226,7 @@
 
 private:
     WebCoreAVFResourceLoader& m_parent;
-    std::unique_ptr<ResourceResponse> m_response;
+    ResourceResponse m_response;
     RefPtr<SharedBuffer> m_buffer;
 };
 
@@ -232,14 +233,11 @@
 DataURLResourceMediaLoader::DataURLResourceMediaLoader(WebCoreAVFResourceLoader& parent, ResourceRequest&& request)
     : m_parent(parent)
 {
-    ASSERT(request.url().protocolIsData());
+    RELEASE_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());
+    if (auto result = DataURLDecoder::decode(request.url(), DataURLDecoder::Mode::ForgivingBase64)) {
+        m_response = ResourceResponse::dataURLResponse(request.url(), *result);
+        m_buffer = SharedBuffer::create(WTFMove(result->data));
     }
 
     callOnMainThread([this, weakThis = makeWeakPtr(*this)] {
@@ -246,11 +244,11 @@
         if (!weakThis)
             return;
 
-        if (!m_buffer || !m_response) {
+        if (!m_buffer || m_response.isNull()) {
             m_parent.loadFailed(ResourceError(ResourceError::Type::General));
             return;
         }
-        m_parent.responseReceived(*m_response);
+        m_parent.responseReceived(m_response);
         if (!weakThis)
             return;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to