Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: de82d628262585b0a92b33ddd5321b8ee34fa6f9
      
https://github.com/WebKit/WebKit/commit/de82d628262585b0a92b33ddd5321b8ee34fa6f9
  Author: Devin Rousso <[email protected]>
  Date:   2026-08-10 (Mon, 10 Aug 2026)

  Changed paths:
    A LayoutTests/inspector/canvas/memory-bitmaprenderer-expected.txt
    A LayoutTests/inspector/canvas/memory-bitmaprenderer.html
    A LayoutTests/inspector/canvas/memory-webgl-expected.txt
    A LayoutTests/inspector/canvas/memory-webgl.html
    A LayoutTests/inspector/canvas/memory-webgpu-expected.txt
    A LayoutTests/inspector/canvas/memory-webgpu.html
    M LayoutTests/platform/glib/TestExpectations
    M Source/JavaScriptCore/inspector/protocol/Canvas.json
    M Source/WebCore/Modules/WebGPU/GPUBuffer.cpp
    M Source/WebCore/Modules/WebGPU/GPUDevice.cpp
    M Source/WebCore/Modules/WebGPU/GPUDevice.h
    M Source/WebCore/Modules/WebGPU/GPUTexture.cpp
    M Source/WebCore/Modules/WebGPU/GPUTexture.h
    M Source/WebCore/html/canvas/GPUCanvasContextCocoa.mm
    M Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
    M Source/WebCore/html/canvas/WebGLRenderingContextBase.h
    M Source/WebCore/inspector/InspectorCanvas.cpp
    M Source/WebCore/inspector/InspectorInstrumentation.cpp
    M Source/WebCore/inspector/InspectorInstrumentation.h
    M Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
    M Source/WebCore/inspector/agents/InspectorCanvasAgent.h
    M Source/WebCore/platform/graphics/GraphicsContextGL.cpp
    M Source/WebCore/platform/graphics/GraphicsContextGL.h
    M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp
    M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h
    M Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
    M Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.js
    M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp
    M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h
    M 
Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLInitializationState.h
    M 
Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLInitializationState.serialization.in
    M Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp
    M Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h
    M 
Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in
    M Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm
    M Tools/TestWebKitAPI/Tests/WebCore/glib/GraphicsContextGLTextureMapper.cpp

  Log Message:
  -----------
  Web inspector should show memory use data for canvas and WebGL
https://bugs.webkit.org/show_bug.cgi?id=190546

Reviewed by Mike Wyrzykowski.

Include associated graphics resources in Web Inspector's canvas memory estimate.
Keep the estimate cheap and deliberately approximate; it only needs to put the 
reported cost in the right ballpark.

* Source/WebCore/platform/graphics/GraphicsContextGL.h:
(WebCore::GraphicsContextGL::Client::didChangeMemoryCost): Added.
(WebCore::GraphicsContextGL::estimatedMemoryCost): Added.
* Source/WebCore/platform/graphics/GraphicsContextGL.cpp:
(WebCore::GraphicsContextGL::didChangeMemoryCost): Added.
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h:
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::estimatedMemoryCost): Added.
(WebCore::GraphicsContextGLANGLE::renderbufferStorage):
(WebCore::GraphicsContextGLANGLE::texImage2D):
(WebCore::GraphicsContextGLANGLE::compressedTexImage2D):
(WebCore::GraphicsContextGLANGLE::reshape):
(WebCore::GraphicsContextGLANGLE::bufferData):
(WebCore::GraphicsContextGLANGLE::renderbufferStorageMultisample):
(WebCore::GraphicsContextGLANGLE::renderbufferStorageMultisampleANGLE):
(WebCore::GraphicsContextGLANGLE::texStorage2D):
(WebCore::GraphicsContextGLANGLE::texStorage3D):
(WebCore::GraphicsContextGLANGLE::texImage3D):
(WebCore::GraphicsContextGLANGLE::compressedTexImage3D):
(WebCore::GraphicsContextGLANGLE::copyTexImage2D):
(WebCore::GraphicsContextGLANGLE::generateMipmap):
(WebCore::GraphicsContextGLANGLE::deleteBuffer):
(WebCore::GraphicsContextGLANGLE::deleteRenderbuffer):
(WebCore::GraphicsContextGLANGLE::deleteTexture):
Use `EGL_ANGLE_memory_usage_report` to include live buffer, texture, and 
renderbuffer allocations from the context's share group.
Notify the context client after ANGLE operations that can resize or destroy 
those resources.

* 
Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLInitializationState.serialization.in:
* 
Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLInitializationState.h:
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h:
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::estimatedMemoryCostForIPC): Added.
(WebKit::RemoteGraphicsContextGL::workQueueInitialize):
(WebKit::RemoteGraphicsContextGL::didChangeMemoryCost): Added.
(WebKit::RemoteGraphicsContextGL::updateMemoryCost): Added.
* 
Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in:
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::estimatedMemoryCostFromIPC): Added.
(WebKit::RemoteGraphicsContextGLProxy::initialize):
(WebKit::RemoteGraphicsContextGLProxy::estimatedMemoryCost): Added.
(WebKit::RemoteGraphicsContextGLProxy::memoryCostChanged): Added.
(WebKit::RemoteGraphicsContextGLProxy::handleMessageToRemovedDestination):
Carry the initial estimate in `WasCreated`, cache it in the WebProcess, and 
only send `MemoryCostChanged` when a coalesced GPU process query changes the 
value.
Feed cache updates through `GraphicsContextGL::Client` so WebGL's normal memory 
update dispatches `canvasMemoryChanged` without synchronous GPU process IPC.

* Source/WebCore/html/canvas/WebGLRenderingContextBase.h:
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::forceLostContext):
(WebCore::WebGLRenderingContextBase::didChangeMemoryCost): Added.
(WebCore::WebGLRenderingContextBase::scheduleMemoryCostUpdate): Added.
(WebCore::WebGLRenderingContextBase::updateMemoryCost):
Preserve the default framebuffer estimate and add ANGLE's cached resource 
estimate.
Coalesce resource changes onto the `WebGL` task queue and immediately clear the 
total when the context is lost.

* Source/WebCore/Modules/WebGPU/GPUBuffer.cpp:
(WebCore::GPUBuffer::~GPUBuffer):
(WebCore::GPUBuffer::destroy):
* Source/WebCore/Modules/WebGPU/GPUTexture.h:
* Source/WebCore/Modules/WebGPU/GPUTexture.cpp:
(WebCore::GPUTexture::~GPUTexture):
(WebCore::GPUTexture::destroy):
(WebCore::GPUTexture::memoryCost): Added.
* Source/WebCore/Modules/WebGPU/GPUDevice.h:
* Source/WebCore/Modules/WebGPU/GPUDevice.cpp:
(WebCore::GPUDevice::memoryCost): Added.
(WebCore::GPUDevice::notifyMemoryCostChanged): Added.
(WebCore::GPUDevice::didChangeBufferMemoryCost): Added.
(WebCore::GPUDevice::didChangeTextureMemoryCost): Added.
(WebCore::GPUDevice::willDestroyBuffer): Added.
(WebCore::GPUDevice::willDestroyTexture): Added.
(WebCore::GPUDevice::destroy):
(WebCore::GPUDevice::createBuffer):
(WebCore::GPUDevice::createTexture):
Track live device-created buffers and textures without extending their 
lifetime, and notify Inspector when their cost changes.
Use existing buffer sizes and WebGPU texture layout helpers for a ballpark 
estimate that includes mip levels, array layers, 3D depth, sample counts, and 
depth/stencil aspects.
Make destruction idempotent so each resource only changes the total once.

* Source/WebCore/html/canvas/GPUCanvasContextCocoa.mm:
(WebCore::GPUCanvasContextCocoa::updateMemoryCost):
Use the same texture estimate for the presentation texture.

* Source/JavaScriptCore/inspector/protocol/Canvas.json:
* Source/WebCore/inspector/InspectorInstrumentation.h:
* Source/WebCore/inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didChangeWebGPUMemory): Added.
(WebCore::InspectorInstrumentation::didChangeWebGPUMemoryImpl): Added.
* Source/WebCore/inspector/agents/InspectorCanvasAgent.h:
* Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::didChangeWebGPUMemory): Added.
* Source/WebCore/inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::memoryCost):
Include WebGPU device resources in the Inspector canvas total and dispatch the 
existing `canvasMemoryChanged` event when it changes.

* Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js:
* Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.js:
(WI.CanvasDetailsSidebarPanel):
Describe the value as an estimate that includes associated graphics resources.

* Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm:
(TestWebKitAPI::MockGraphicsContextGLClient::didChangeMemoryCost): Added.
* Tools/TestWebKitAPI/Tests/WebCore/glib/GraphicsContextGLTextureMapper.cpp:
(TestWebKitAPI::MockGraphicsContextGLClient::didChangeMemoryCost): Added.
* LayoutTests/inspector/canvas/memory-bitmaprenderer.html: Added.
* LayoutTests/inspector/canvas/memory-bitmaprenderer-expected.txt: Added.
* LayoutTests/inspector/canvas/memory-webgl.html: Added.
* LayoutTests/inspector/canvas/memory-webgl-expected.txt: Added.
* LayoutTests/inspector/canvas/memory-webgpu.html: Added.
* LayoutTests/inspector/canvas/memory-webgpu-expected.txt: Added.
* LayoutTests/platform/glib/TestExpectations:

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



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

Reply via email to