Title: [274873] trunk/Source/WebCore
- Revision
- 274873
- Author
- [email protected]
- Date
- 2021-03-23 09:18:25 -0700 (Tue, 23 Mar 2021)
Log Message
Only send image across XPC to GPU process if it changes.
https://bugs.webkit.org/show_bug.cgi?id=223298
<rdar://problem/75559236>
Patch by Jean-Yves Avenard <[email protected]> on 2021-03-23
Reviewed by Eric Carlson.
No change in observable functionality.
* platform/NowPlayingManager.cpp:
(WebCore::NowPlayingManager::setNowPlayingInfo): On first image change we store it to a local member variable and set imageData to null.
(WebCore::NowPlayingManager::setNowPlayingInfoPrivate): Check if imageData is null, and if so use cache value.
* platform/NowPlayingManager.h: New member to store cache.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (274872 => 274873)
--- trunk/Source/WebCore/ChangeLog 2021-03-23 15:56:50 UTC (rev 274872)
+++ trunk/Source/WebCore/ChangeLog 2021-03-23 16:18:25 UTC (rev 274873)
@@ -1,3 +1,18 @@
+2021-03-23 Jean-Yves Avenard <[email protected]>
+
+ Only send image across XPC to GPU process if it changes.
+ https://bugs.webkit.org/show_bug.cgi?id=223298
+ <rdar://problem/75559236>
+
+ Reviewed by Eric Carlson.
+
+ No change in observable functionality.
+
+ * platform/NowPlayingManager.cpp:
+ (WebCore::NowPlayingManager::setNowPlayingInfo): On first image change we store it to a local member variable and set imageData to null.
+ (WebCore::NowPlayingManager::setNowPlayingInfoPrivate): Check if imageData is null, and if so use cache value.
+ * platform/NowPlayingManager.h: New member to store cache.
+
2021-03-23 Chris Dumez <[email protected]>
Add assertions to guard against heap allocations on the audio thread
Modified: trunk/Source/WebCore/platform/NowPlayingManager.cpp (274872 => 274873)
--- trunk/Source/WebCore/platform/NowPlayingManager.cpp 2021-03-23 15:56:50 UTC (rev 274872)
+++ trunk/Source/WebCore/platform/NowPlayingManager.cpp 2021-03-23 16:18:25 UTC (rev 274873)
@@ -77,6 +77,15 @@
if (m_nowPlayingInfo && *m_nowPlayingInfo == nowPlayingInfo)
return false;
m_nowPlayingInfo = nowPlayingInfo;
+ // We do not want to send the artwork's image over each time nowPlayingInfo gets updated.
+ // So if present we store it once locally. On the receiving end, a null imageData indicates to use the cached image.
+ if (!nowPlayingInfo.artwork)
+ m_nowPlayingInfoArtwork = { };
+ else if (!m_nowPlayingInfoArtwork || nowPlayingInfo.artwork->src != m_nowPlayingInfoArtwork->src)
+ m_nowPlayingInfoArtwork = ArtworkCache { nowPlayingInfo.artwork->src, nowPlayingInfo.artwork->imageData };
+ else
+ m_nowPlayingInfo->artwork->imageData = nullptr;
+
setNowPlayingInfoPrivate(*m_nowPlayingInfo);
m_setAsNowPlayingApplication = true;
return true;
@@ -86,6 +95,13 @@
{
setSupportsSeeking(nowPlayingInfo.supportsSeeking);
#if PLATFORM(COCOA)
+ if (nowPlayingInfo.artwork && !nowPlayingInfo.artwork->imageData) {
+ ASSERT(m_nowPlayingInfoArtwork, "cached value must have been initialized");
+ NowPlayingInfo nowPlayingInfoRebuilt = nowPlayingInfo;
+ nowPlayingInfoRebuilt.artwork->imageData = m_nowPlayingInfoArtwork->imageData;
+ MediaSessionManagerCocoa::setNowPlayingInfo(!m_setAsNowPlayingApplication, nowPlayingInfoRebuilt);
+ return;
+ }
MediaSessionManagerCocoa::setNowPlayingInfo(!m_setAsNowPlayingApplication, nowPlayingInfo);
#else
(void)nowPlayingInfo;
Modified: trunk/Source/WebCore/platform/NowPlayingManager.h (274872 => 274873)
--- trunk/Source/WebCore/platform/NowPlayingManager.h 2021-03-23 15:56:50 UTC (rev 274872)
+++ trunk/Source/WebCore/platform/NowPlayingManager.h 2021-03-23 16:18:25 UTC (rev 274873)
@@ -68,6 +68,11 @@
std::unique_ptr<RemoteCommandListener> m_remoteCommandListener;
WeakPtr<Client> m_client;
Optional<NowPlayingInfo> m_nowPlayingInfo;
+ struct ArtworkCache {
+ String src;
+ RefPtr<SharedBuffer> imageData;
+ };
+ Optional<ArtworkCache> m_nowPlayingInfoArtwork;
bool m_setAsNowPlayingApplication { false };
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes