Title: [274802] trunk/Source/WebCore
Revision
274802
Author
[email protected]
Date
2021-03-22 14:47:51 -0700 (Mon, 22 Mar 2021)

Log Message

Always perform image decoding in the web content process.
https://bugs.webkit.org/show_bug.cgi?id=223290
<rdar://problem/75559243>

Patch by Jean-Yves Avenard <[email protected]> on 2021-03-22
Reviewed by Eric Carlson.

No change in externally observable behaviour.

* Modules/mediasession/MediaMetadata.cpp:
(WebCore::ArtworkImageLoader::notifyFinished): We decode the image into a BitmapImage and handle all potential failures getting there.
* platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::setNowPlayingInfo): remove FIXME comment.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274801 => 274802)


--- trunk/Source/WebCore/ChangeLog	2021-03-22 21:34:09 UTC (rev 274801)
+++ trunk/Source/WebCore/ChangeLog	2021-03-22 21:47:51 UTC (rev 274802)
@@ -1,3 +1,18 @@
+2021-03-22  Jean-Yves Avenard  <[email protected]>
+
+        Always perform image decoding in the web content process.
+        https://bugs.webkit.org/show_bug.cgi?id=223290
+        <rdar://problem/75559243>
+
+        Reviewed by Eric Carlson.
+
+        No change in externally observable behaviour.
+
+        * Modules/mediasession/MediaMetadata.cpp:
+        (WebCore::ArtworkImageLoader::notifyFinished): We decode the image into a BitmapImage and handle all potential failures getting there.
+        * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+        (WebCore::MediaSessionManagerCocoa::setNowPlayingInfo): remove FIXME comment.
+
 2021-03-22  Wenson Hsieh  <[email protected]>
 
         [iOS] Composition text is not initially highlighted when typing in text fields using Pinyin keyboard

Modified: trunk/Source/WebCore/Modules/mediasession/MediaMetadata.cpp (274801 => 274802)


--- trunk/Source/WebCore/Modules/mediasession/MediaMetadata.cpp	2021-03-22 21:34:09 UTC (rev 274801)
+++ trunk/Source/WebCore/Modules/mediasession/MediaMetadata.cpp	2021-03-22 21:47:51 UTC (rev 274802)
@@ -28,10 +28,13 @@
 
 #if ENABLE(MEDIA_SESSION)
 
+#include "BitmapImage.h"
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
 #include "Document.h"
+#include "GraphicsContext.h"
 #include "Image.h"
+#include "ImageBuffer.h"
 #include "MediaImage.h"
 #include "MediaMetadataInit.h"
 #include "SpaceSplitString.h"
@@ -69,7 +72,21 @@
 void ArtworkImageLoader::notifyFinished(CachedResource& resource, const NetworkLoadMetrics&)
 {
     ASSERT_UNUSED(resource, &resource == m_cachedImage);
-    m_callback(m_cachedImage->loadFailedOrCanceled() ? nullptr : m_cachedImage->image());
+    if (m_cachedImage->loadFailedOrCanceled() || !m_cachedImage->image() || !m_cachedImage->image()->data() || m_cachedImage->image()->data()->isEmpty()) {
+        m_callback(nullptr);
+        return;
+    }
+    // Sanitize the image by decoding it into a BitmapImage.
+    RefPtr<SharedBuffer> bufferToSanitize = m_cachedImage->image()->data();
+    auto bitmapImage = BitmapImage::create();
+    bitmapImage->setData(WTFMove(bufferToSanitize), true);
+    auto imageBuffer = ImageBuffer::create(bitmapImage->size(), RenderingMode::Unaccelerated);
+    if (!imageBuffer) {
+        m_callback(nullptr);
+        return;
+    }
+    imageBuffer->context().drawImage(bitmapImage.get(), FloatPoint::zero());
+    m_callback(bitmapImage.ptr());
 }
 
 ExceptionOr<Ref<MediaMetadata>> MediaMetadata::create(ScriptExecutionContext& context, Optional<MediaMetadataInit>&& init)

Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm (274801 => 274802)


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-03-22 21:34:09 UTC (rev 274801)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-03-22 21:47:51 UTC (rev 274802)
@@ -309,8 +309,6 @@
         CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoElapsedTime, cfCurrentTime.get());
     }
     if (nowPlayingInfo.artwork) {
-        // FIXME: we should only pass a decompressed image here and have the decompression performed in the webcontent process.
-        // see https://bugs.webkit.org/show_bug.cgi?id=223290.
         auto nsArtwork = nowPlayingInfo.artwork->imageData->createNSData();
         CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoArtworkData, nsArtwork.get());
         CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoArtworkMIMEType, nowPlayingInfo.artwork->mimeType.createCFString().get());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to