Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 186929fd217c12e69cbb3e31cb40b90760b0f799
      
https://github.com/WebKit/WebKit/commit/186929fd217c12e69cbb3e31cb40b90760b0f799
  Author: Mike Wyrzykowski <[email protected]>
  Date:   2026-08-07 (Fri, 07 Aug 2026)

  Changed paths:
    M Source/WebCore/Modules/WebGPU/GPUCompositorIntegration.h
    M 
Source/WebCore/Modules/WebGPU/Implementation/WebGPUCompositorIntegrationImpl.cpp
    M 
Source/WebCore/Modules/WebGPU/Implementation/WebGPUCompositorIntegrationImpl.h
    M 
Source/WebCore/Modules/WebGPU/Implementation/WebGPUPresentationContextImpl.cpp
    M 
Source/WebCore/Modules/WebGPU/Implementation/WebGPUPresentationContextImpl.h
    M Source/WebCore/Modules/WebGPU/InternalAPI/WebGPUCompositorIntegration.h
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/html/canvas/CanvasRenderingContext.h
    M Source/WebCore/html/canvas/GPUCanvasContextCocoa.h
    M Source/WebCore/html/canvas/GPUCanvasContextCocoa.mm
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    A Source/WebCore/platform/graphics/WebGPUFramePacer.cpp
    A Source/WebCore/platform/graphics/WebGPUFramePacer.h
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
    M Source/WebGPU/WebGPU/CommandBuffer.h
    M Source/WebGPU/WebGPU/CommandBuffer.mm
    M Source/WebGPU/WebGPU/CommandEncoder.h
    M Source/WebGPU/WebGPU/CommandEncoder.mm
    M Source/WebGPU/WebGPU/PresentationContext.h
    M Source/WebGPU/WebGPU/PresentationContext.mm
    M Source/WebGPU/WebGPU/PresentationContextIOSurface.h
    M Source/WebGPU/WebGPU/PresentationContextIOSurface.mm
    M Source/WebGPU/WebGPU/Texture.h
    M Source/WebGPU/WebGPU/Texture.mm
    M Source/WebGPU/WebGPU/TextureView.mm
    M Source/WebGPU/WebGPU/WebGPUExt.h
    M Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.cpp
    M Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.h
    M 
Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.messages.in
    M 
Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteCompositorIntegrationProxy.cpp
    M 
Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteCompositorIntegrationProxy.h
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WebCore/WebGPUFramePacer.cpp

  Log Message:
  -----------
  Performance seems slower with attached shader in Safari
https://bugs.webkit.org/show_bug.cgi?id=320866
rdar://183571775

Reviewed by Dan Glastonbury.

A WebGPU canvas whose per-frame GPU work cannot finish within a single
display VSync, e.g., a complex shader, kept requesting presentation at 60Hz,
so frames backed up and were displayed unevenly, making the animation look 
choppy.

Instead measure the presented frame's GPU cost in the GPU process. 
WebGPUFramePacer
consumes those costs and picks the highest sustainable rate, so a single spike 
does
not change the rate. GPUCanvasContextCocoa drives the pacer and registers
with the page so the page's rendering update rate is clamped to the
slowest requesting canvas.

Test: Tools/TestWebKitAPI/Tests/WebCore/WebGPUFramePacer.cpp

* Source/WebCore/Modules/WebGPU/GPUCompositorIntegration.h:
(WebCore::GPUCompositorIntegration::lastFrameGPUCost const):
* 
Source/WebCore/Modules/WebGPU/Implementation/WebGPUCompositorIntegrationImpl.cpp:
(WebCore::WebGPU::CompositorIntegrationImpl::lastFrameGPUCost const):
* 
Source/WebCore/Modules/WebGPU/Implementation/WebGPUCompositorIntegrationImpl.h:
* 
Source/WebCore/Modules/WebGPU/Implementation/WebGPUPresentationContextImpl.cpp:
(WebCore::WebGPU::PresentationContextImpl::lastFrameGPUCost const):
* Source/WebCore/Modules/WebGPU/Implementation/WebGPUPresentationContextImpl.h:
* Source/WebCore/Modules/WebGPU/InternalAPI/WebGPUCompositorIntegration.h:
(WebCore::WebGPU::CompositorIntegration::lastFrameGPUCost const):
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/html/canvas/CanvasRenderingContext.h:
(WebCore::CanvasRenderingContext::preferredRenderingUpdateFramesPerSecond 
const):
* Source/WebCore/html/canvas/GPUCanvasContextCocoa.h:
* Source/WebCore/html/canvas/GPUCanvasContextCocoa.mm:
(WebCore::GPUCanvasContextCocoa::surfaceBufferToImageBuffer):
(WebCore::GPUCanvasContextCocoa::unconfigure):
(WebCore::GPUCanvasContextCocoa::prepareForDisplay):
(WebCore::GPUCanvasContextCocoa::page const):
(WebCore::GPUCanvasContextCocoa::updateFramePacing):
(WebCore::GPUCanvasContextCocoa::preferredRenderingUpdateFramesPerSecond const):
* Source/WebCore/page/Page.cpp:
(WebCore::Page::preferredRenderingUpdateFramesPerSecond const):
(WebCore::Page::addGPUCanvasRequestingRenderingUpdatePacing):
(WebCore::Page::removeGPUCanvasRequestingRenderingUpdatePacing):
* Source/WebCore/page/Page.h:
* Source/WebCore/platform/graphics/WebGPUFramePacer.cpp: Added.
(WebCore::WebGPUFramePacer::setDisplayNominalFramesPerSecond):
(WebCore::WebGPUFramePacer::rebuildDivisorLadder):
(WebCore::WebGPUFramePacer::reset):
(WebCore::WebGPUFramePacer::recordFrame):
(WebCore::WebGPUFramePacer::runController):
(WebCore::WebGPUFramePacer::preferredFramesPerSecond const):
* Source/WebCore/platform/graphics/WebGPUFramePacer.h: Added.
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::visit):
* Source/WebGPU/WebGPU/CommandBuffer.mm:
(WebGPU::CommandBuffer::makeInvalidDueToCommit):
* Source/WebGPU/WebGPU/CommandEncoder.h:
* Source/WebGPU/WebGPU/CommandEncoder.mm:
(WebGPU::CommandEncoder::recordGPUExecutionWindowOnCanvasTextures const):
* Source/WebGPU/WebGPU/PresentationContext.h:
(WebGPU::PresentationContext::lastFrameGPUCost const):
* Source/WebGPU/WebGPU/PresentationContext.mm:
(wgpuSurfaceGetLastFrameGPUCostSeconds):
* Source/WebGPU/WebGPU/PresentationContextIOSurface.h:
* Source/WebGPU/WebGPU/PresentationContextIOSurface.mm:
* Source/WebGPU/WebGPU/Texture.h:
(WebGPU::Texture::WTF_GUARDED_BY_LOCK):
* Source/WebGPU/WebGPU/Texture.mm:
(WebGPU::Texture::recordGPUExecutionWindow const):
(WebGPU::Texture::gpuFrameCost const):
(WebGPU::Texture::resetGPUFrameCost const):
(WebGPU::Texture::setCommandEncoder const):
* Source/WebGPU/WebGPU/TextureView.mm:
(WebGPU::TextureView::setCommandEncoder const):
* Source/WebGPU/WebGPU/WebGPUExt.h:
* Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.cpp:
(WebKit::RemoteCompositorIntegration::prepareForDisplay):
* Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.h:
* 
Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.messages.in:
* 
Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteCompositorIntegrationProxy.cpp:
(WebKit::WebGPU::RemoteCompositorIntegrationProxy::prepareForDisplay):
* 
Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteCompositorIntegrationProxy.h:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebCore/WebGPUFramePacer.cpp: Added.
(TestWebKitAPI::feedFrames):
(TestWebKitAPI::TEST(WebGPUFramePacer, NoRateBeforeWarmUp)):
(TestWebKitAPI::TEST(WebGPUFramePacer, FullRefreshContentIsNotPaced)):
(TestWebKitAPI::TEST(WebGPUFramePacer, ConvergesTo20For45msFrames)):
(TestWebKitAPI::TEST(WebGPUFramePacer, ConvergesTo12For83msFrames)):
(TestWebKitAPI::TEST(WebGPUFramePacer, ConvergedRateIsStable)):
(TestWebKitAPI::TEST(WebGPUFramePacer, SingleSpikeDoesNotStepDown)):
(TestWebKitAPI::TEST(WebGPUFramePacer, SustainedOverloadStepsDown)):
(TestWebKitAPI::TEST(WebGPUFramePacer, IdleCanvasStopsPacing)):
(TestWebKitAPI::TEST(WebGPUFramePacer, DivisorLadderFollows120HzDisplay)):
(TestWebKitAPI::TEST(WebGPUFramePacer, ClosedLoopDoesNotRatchet)):
(TestWebKitAPI::TEST(WebGPUFramePacer, RecoversWhenWorkloadEases)):

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



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

Reply via email to