Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6bf6c9f35c739bb60113cc258516b3a12cd339c4
      
https://github.com/WebKit/WebKit/commit/6bf6c9f35c739bb60113cc258516b3a12cd339c4
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2026-04-23 (Thu, 23 Apr 2026)

  Changed paths:
    M Source/WebCore/Headers.cmake
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    A Source/WebCore/platform/graphics/MediaTimeUpdateData.h
    M Source/WebCore/platform/graphics/avfoundation/AudioVideoRendererAVFObjC.mm
    M Source/WebKit/GPUProcess/media/RemoteAudioVideoRendererProxyManager.cpp
    M Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/WebProcess/GPU/media/AudioVideoRendererRemote.cpp
    M Source/WebKit/WebProcess/GPU/media/AudioVideoRendererRemote.h
    M Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
    M Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h
    M Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in
    M Source/WebKit/WebProcess/GPU/media/MediaTimeUpdateData.serialization.in
    M Source/WebKit/WebProcess/GPU/media/RemoteAudioVideoRendererState.h
    M 
Source/WebKit/WebProcess/GPU/media/RemoteAudioVideoRendererState.serialization.in

  Log Message:
  -----------
  Use a TimeProgressEstimator to interpolate 
AudioVideoRendererRemote::currentTime() between GPU updates
https://bugs.webkit.org/show_bug.cgi?id=307515
rdar://170115677

Reviewed by Jer Noble.

The GPU process pushes a RemoteAudioVideoRendererState snapshot to the
WebContent process every 250ms (constant now defined in one place).
Previously, AudioVideoRendererRemote::currentTime() returned the cached
value verbatim, so observers saw time advance in stepwise jumps. This
patch interpolates between updates and prepares the renderer for an
upcoming change that will make GPU-side updates event-driven rather than
periodic.

* Source/WebCore/platform/graphics/MediaTimeUpdateData.h: Promoted from
WebKit:: to WebCore:: namespace so it can be reused by the
AudioVideoRenderer pipeline. Replaced the bool timeIsProgressing field
with a double effectiveRate (0 means not progressing). A
timeIsProgressing() accessor returning effectiveRate != 0 preserves
existing call sites.
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj: Register the new
MediaTimeUpdateData.h as a Private WebCore header (required by both
CMake and Xcode builds).

* Source/WebKit/WebProcess/GPU/media/MediaTimeUpdateData.serialization.in:
Match the struct change (double effectiveRate instead of bool).

* Source/WebKit/WebProcess/GPU/media/RemoteAudioVideoRendererState.h:
* 
Source/WebKit/WebProcess/GPU/media/RemoteAudioVideoRendererState.serialization.in:
Replaced currentTime + timeIsProgressing fields with a single
WebCore::MediaTimeUpdateData timeUpdateData carrying currentTime,
effectiveRate, and wallTime. Dropped the redundant top-level
effectiveRate (now sourced from timeUpdateData.effectiveRate). Added a
shared remoteAudioVideoRendererUpdateInterval constant (250ms) used by
both the GPU-side time observer and the client-side estimator.

* Source/WebKit/GPUProcess/media/RemoteAudioVideoRendererProxyManager.cpp:
(WebKit::RemoteAudioVideoRendererProxyManager::create): Use the shared
update-interval constant for setTimeObserver().
(WebKit::RemoteAudioVideoRendererProxyManager::play):
(WebKit::RemoteAudioVideoRendererProxyManager::pause):
(WebKit::RemoteAudioVideoRendererProxyManager::setRate): After applying
the state change, immediately send a StateUpdate so the client
estimator gets the new effectiveRate and resumes extrapolation without
waiting for the next periodic tick.
(WebKit::RemoteAudioVideoRendererProxyManager::stateFor): Build the new
timeUpdateData. Stamps effectiveRate = timeIsProgressing() ?
effectiveRate() : 0.0 and wallTime = MonotonicTime::now().

* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::timeUpdateData): Same effectiveRate-from-timeIsProgressing
synthesis applied to the MediaPlayer pipeline.

* Source/WebKit/WebProcess/GPU/media/AudioVideoRendererRemote.h:
* Source/WebKit/WebProcess/GPU/media/AudioVideoRendererRemote.cpp:
Added an inner TimeProgressEstimator class with its own lock (a
dedicated lock keeps the hot currentTime() read path off the busy
m_lock). The estimator extrapolates as cachedTime + effectiveRate *
min(now - wallTime, updateInterval); the cap prevents drift when
updates pause. A single std::atomic<double> m_effectiveRate replaces
the pair (m_rate, m_timeIsProgressing); timeIsProgressing() returns
m_effectiveRate != 0 without taking the lock.
setRate() rebases the cached anchor using the old effectiveRate and
suspends extrapolation until the next setTime() via
m_forceUseCachedTime, mirroring the rateChanged() handoff pattern.
pause() rebases the cached anchor and drops m_effectiveRate to 0; no
freeze flag is needed because the !rate short-circuit already returns
cachedTime. AudioVideoRendererRemote::pause() calls it so the estimator
freezes immediately instead of waiting for the GPU reply.
Added a stall cap: notifyTimeReachedAndStall pushes the boundary into
the estimator via setStallCap(); currentTime() then clamps the returned
value to that boundary (after the monotonicity max-clamp, so we can
clip back from any prior overshoot). cancelTimeReachedAction() clears
it. Without this, the interpolating estimator could briefly report a
currentTime past buffered.end(0) before the GPU's StallTimeReached IPC
landed, breaking tests like media-managedmse-resume-after-stall.html.
Removed the redundant CachedState::effectiveRate field; effectiveRate()
now reads from the estimator. stall() likewise delegates to
m_timeEstimator.setRate(0). Routed currentTime() and
timeIsProgressing() through the estimator; seek paths feed the
estimator directly with a fresh MediaTimeUpdateData (effectiveRate=0).

* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
Applied the same m_rate + m_timeIsProgressing collapse to the existing
TimeProgressEstimator so the two estimators stay symmetric and consume
the new MediaTimeUpdateData shape. Updated log lines to print
effectiveRate instead of timeIsProgressing.

* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: Added the
missing header: <WebCore/LegacyCDMSession.h> directive next to the
using WebCore::LegacyCDMSessionClient::MediaKeyErrorCode declaration.
Latent issue exposed when the new MediaTimeUpdateData.h entry shifted
unified-source bucketing.

Canonical link: https://commits.webkit.org/311867@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to