Title: [284102] trunk/Source/WebKit
- Revision
- 284102
- Author
- [email protected]
- Date
- 2021-10-13 10:28:28 -0700 (Wed, 13 Oct 2021)
Log Message
WebGL video texture upload is very slow due to excessive transfer of the video pixel buffer
https://bugs.webkit.org/show_bug.cgi?id=231425
Patch by Kimmo Kinnunen <[email protected]> on 2021-10-13
Reviewed by Youenn Fablet.
Typical WebGL content requests the videos to be uploaded to a texture
once per render loop update, even though the video has not changed.
The video pixel buffer is slow to transfer across IPC. It should be transferred
only when it has changed.
MediaPlayerPrivateAVFoundationObjC and MediaPlayerPrivateMediaSourceAVFObjC hold
the last requested pixel buffer ref. They will update it or discard it only
when pixelBufferForCurrentTime() is called.
Cache the pixel buffer to MediaPlayerPrivateRemote (GPUP side proxy)
Cache the pixel buffer to RemoteMediaPlayerProxy (WebP side proxy)
The caches increase the total memory use only during the duration
of the call, since after the ref has been updated, it refers
to the one always held in the original objects (MediaPlayerPrivateAVFoundationObjC
and MediaPlayerPrivateMediaSourceAVFObjC)
No new tests, fixes a perf regression wrt GPUP media.
* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::invalidate):
* GPUProcess/media/RemoteMediaPlayerProxy.h:
* GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
* GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
(WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
(WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTimeIfChanged):
(WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime): Deleted.
* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
* WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
(WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (284101 => 284102)
--- trunk/Source/WebKit/ChangeLog 2021-10-13 17:20:20 UTC (rev 284101)
+++ trunk/Source/WebKit/ChangeLog 2021-10-13 17:28:28 UTC (rev 284102)
@@ -1,3 +1,41 @@
+2021-10-13 Kimmo Kinnunen <[email protected]>
+
+ WebGL video texture upload is very slow due to excessive transfer of the video pixel buffer
+ https://bugs.webkit.org/show_bug.cgi?id=231425
+
+ Reviewed by Youenn Fablet.
+
+ Typical WebGL content requests the videos to be uploaded to a texture
+ once per render loop update, even though the video has not changed.
+ The video pixel buffer is slow to transfer across IPC. It should be transferred
+ only when it has changed.
+
+ MediaPlayerPrivateAVFoundationObjC and MediaPlayerPrivateMediaSourceAVFObjC hold
+ the last requested pixel buffer ref. They will update it or discard it only
+ when pixelBufferForCurrentTime() is called.
+
+ Cache the pixel buffer to MediaPlayerPrivateRemote (GPUP side proxy)
+ Cache the pixel buffer to RemoteMediaPlayerProxy (WebP side proxy)
+
+ The caches increase the total memory use only during the duration
+ of the call, since after the ref has been updated, it refers
+ to the one always held in the original objects (MediaPlayerPrivateAVFoundationObjC
+ and MediaPlayerPrivateMediaSourceAVFObjC)
+
+ No new tests, fixes a perf regression wrt GPUP media.
+
+ * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+ (WebKit::RemoteMediaPlayerProxy::invalidate):
+ * GPUProcess/media/RemoteMediaPlayerProxy.h:
+ * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
+ * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
+ (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
+ (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTimeIfChanged):
+ (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTime): Deleted.
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+ * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
+
2021-10-13 Per Arne Vollan <[email protected]>
[iOS] Stop including 'util.sb' in the WebContent process' sandbox
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (284101 => 284102)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp 2021-10-13 17:20:20 UTC (rev 284101)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp 2021-10-13 17:28:28 UTC (rev 284102)
@@ -106,6 +106,9 @@
m_sandboxExtension = nullptr;
}
m_renderingResourcesRequest = { };
+#if USE(AVFOUNDATION)
+ m_pixelBufferForCurrentTime = nullptr;
+#endif
}
void RemoteMediaPlayerProxy::getConfiguration(RemoteMediaPlayerConfiguration& configuration)
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (284101 => 284102)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2021-10-13 17:20:20 UTC (rev 284101)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2021-10-13 17:28:28 UTC (rev 284102)
@@ -314,7 +314,7 @@
void nativeImageForCurrentTime(CompletionHandler<void(std::optional<WTF::MachSendRight>&&)>&&);
#endif
#if USE(AVFOUNDATION)
- void pixelBufferForCurrentTime(CompletionHandler<void(RetainPtr<CVPixelBufferRef>&&)>&&);
+ void pixelBufferForCurrentTimeIfChanged(CompletionHandler<void(std::optional<RetainPtr<CVPixelBufferRef>>&&)>&&);
#endif
#if !RELEASE_LOG_DISABLED
@@ -369,7 +369,9 @@
ScopedRenderingResourcesRequest m_renderingResourcesRequest;
bool m_observingTimeChanges { false };
-
+#if USE(AVFOUNDATION)
+ RetainPtr<CVPixelBufferRef> m_pixelBufferForCurrentTime;
+#endif
#if !RELEASE_LOG_DISABLED
const Logger& m_logger;
#endif
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in (284101 => 284102)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2021-10-13 17:20:20 UTC (rev 284101)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2021-10-13 17:28:28 UTC (rev 284102)
@@ -126,7 +126,7 @@
NativeImageForCurrentTime() -> (std::optional<MachSendRight> sendRight) Synchronous
#endif
#if USE(AVFOUNDATION)
- PixelBufferForCurrentTime() -> (RetainPtr<CVPixelBufferRef> pixelBuffer) Synchronous
+ PixelBufferForCurrentTimeIfChanged() -> (std::optional<RetainPtr<CVPixelBufferRef>> pixelBuffer) Synchronous
#endif
PlayAtHostTime(MonotonicTime time)
Modified: trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (284101 => 284102)
--- trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2021-10-13 17:20:20 UTC (rev 284101)
+++ trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2021-10-13 17:28:28 UTC (rev 284102)
@@ -111,13 +111,20 @@
completionHandler(surface->createSendRight());
}
-void RemoteMediaPlayerProxy::pixelBufferForCurrentTime(CompletionHandler<void(RetainPtr<CVPixelBufferRef>&&)>&& completionHandler)
+#if USE(AVFOUNDATION)
+void RemoteMediaPlayerProxy::pixelBufferForCurrentTimeIfChanged(CompletionHandler<void(std::optional<RetainPtr<CVPixelBufferRef>>&&)>&& completionHandler)
{
- RetainPtr<CVPixelBufferRef> result;
+ std::optional<RetainPtr<CVPixelBufferRef>> result;
+ RetainPtr<CVPixelBufferRef> pixelBuffer;
if (m_player)
- result = m_player->pixelBufferForCurrentTime();
+ pixelBuffer = m_player->pixelBufferForCurrentTime();
+ if (m_pixelBufferForCurrentTime != pixelBuffer) {
+ result = pixelBuffer;
+ m_pixelBufferForCurrentTime = WTFMove(pixelBuffer);
+ }
completionHandler(WTFMove(result));
}
+#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (284101 => 284102)
--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2021-10-13 17:20:20 UTC (rev 284101)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2021-10-13 17:28:28 UTC (rev 284102)
@@ -445,6 +445,9 @@
bool m_waitingForKey { false };
bool m_timeIsProgressing { false };
bool m_renderingCanBeAccelerated { false };
+#if USE(AVFOUNDATION)
+ RetainPtr<CVPixelBufferRef> m_pixelBufferForCurrentTime;
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm (284101 => 284102)
--- trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm 2021-10-13 17:20:20 UTC (rev 284101)
+++ trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm 2021-10-13 17:28:28 UTC (rev 284102)
@@ -66,14 +66,17 @@
return NativeImage::create(WTFMove(platformImage));
}
+#if USE(AVFOUNDATION)
RetainPtr<CVPixelBufferRef> MediaPlayerPrivateRemote::pixelBufferForCurrentTime()
{
-
- RetainPtr<CVPixelBufferRef> result;
- if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::PixelBufferForCurrentTime(), Messages::RemoteMediaPlayerProxy::PixelBufferForCurrentTime::Reply(result), m_id))
+ std::optional<RetainPtr<CVPixelBufferRef>> result;
+ if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::PixelBufferForCurrentTimeIfChanged(), Messages::RemoteMediaPlayerProxy::PixelBufferForCurrentTimeIfChanged::Reply(result), m_id))
return nullptr;
- return result;
+ if (result)
+ m_pixelBufferForCurrentTime = WTFMove(*result);
+ return m_pixelBufferForCurrentTime;
}
+#endif
} // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes