← All reports

VideoFrames cannot be created asynchronously in WebContent process

Component: WebKit GPU Process media | 6d5870d

Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.cpp

+void RemoteVideoFrameObjectHeap::add(RemoteVideoFrameReference reference, Ref<WebCore::VideoFrame>&& frame)
+{
+ auto success = m_heap.add(reference, WTF::move(frame));
+ ASSERT_UNUSED(success, success);
+}
...
+static constexpr Seconds defaultTimeout = 10_s;
...
- return m_heap.read(WTF::move(read), 0_s);
+ auto timeout = isInGPUProcessObjectIdentifierDomain(read.identifier().toUInt64()) ? 0_s : defaultTimeout;
+ return m_heap.read(WTF::move(read), timeout);

RemoteVideoFrameObjectHeap in the GPU process maps RemoteVideoFrameReference IDs to live VideoFrame objects. WebContent holds RemoteVideoFrameProxy objects naming those frames and sends the references back when it wants to draw, encode or sample them (WebGL, 2D canvas, WebGPU external textures, WebRTC encoders). Previously the GPU process allocated each ID synchronously and returned it in the reply. IDs come from an ObjectIdentifier domain, and a respawned GPU process restarts from the same base, so an ID from a dead GPU process can name an unrelated frame in the new one.

Now WebContent allocates the reference itself for frames it requests, passing it as a new argument on RemoteGraphicsContextGL::SurfaceBufferToVideoFrame, RemoteAudioVideoRendererProxyManager::CurrentVideoFrame and RemoteMediaPlayerProxy::VideoFrameForCurrentTimeIfChanged. The GPU process stores the frame with the new add(reference, frame) and builds the reply with RemoteVideoFrameProxy::properties(). Frames the GPU process produces on its own (metadata, WebRTC decoder output, capture) still get a GPU-allocated reference, now sent as a separate argument on PushVideoFrameMetadata, CompletedDecoding and VideoFrameAvailable. RemoteVideoFrameProxy::newReadReference() and SharedVideoFrameWriter::write() now take the IPC connection and fail for frames bound to a different GPU process connection.

Before:                                   After:
WebContent        GPUProcess              WebContent             GPUProcess
  │ Request ───────► │                      │ reserve ref (WCP domain)
  │                  ├ heap.add(frame)→ref  │ Request(ref) ───────► │
  │ ◄── Properties(ref) ┤                   │                       ├ props = properties(frame)
  │ (blocks for ID)                         │ ◄── Properties ───────┤ heap.add(ref, frame)
                                            │ newReadReference(conn) -> fails if frame bound
                                            │   to a different GPUP connection

Reserving references in WebContent lets fast paths create video frame references asynchronously, which is groundwork for faster frame transfer. The GPU process now inserts frames under IDs chosen by the less-trusted WebContent process, across WebGL, media player and audio/video renderer entry points. The top-bit domain split keeps the two processes' IDs from colliding, and the connection binding keeps stale IDs from a previous GPU process out.

The trust shift is that IDs now come from the renderer, so the questions are about what the GPU process does with an ID it did not mint: