Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 95810670932e82e28b1967418c8558a4fcfc7146
      
https://github.com/WebKit/WebKit/commit/95810670932e82e28b1967418c8558a4fcfc7146
  Author: Razvan Caliman <[email protected]>
  Date:   2026-05-01 (Fri, 01 May 2026)

  Changed paths:
    M Source/WebCore/inspector/agents/InspectorLayerTreeAgent.cpp
    M Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js

  Log Message:
  -----------
  Navigating with the Layers inspector tab open breaks the visualization
https://bugs.webkit.org/show_bug.cgi?id=307431
rdar://170836910

Reviewed by Devin Rousso and Qianlang Chen.

There's a race condition that occurs between backend and frontend during page 
reload/navigation
while the Layers tab is open resulting in requesting layer snapshots for layers 
that have been
resized to zero during the transition.

Page navigation triggers a `WI.LayerTreeManager.Event.LayerTreeDidChange` event 
which
`WI.Layers3DContentView.prototype._layerTreeDidChange` handles by causing 
layout of the Layers tab.

Layout fetches layers via `WI.Layers3DContentView.prototype.layersForNode()`. 
At this point,
layers exist and have valid sizes. Then for each layer, the frontend calls:
`_populateLayerGroup()` → `_loadLayerTexture()` → `snapshotForLayer()`.

The request for snapshot sends `LayerTreeAgent.requestContent` to the backend. 
But, during the
navigation, the render tree has changed: layers may have been destroyed, lost 
their compositing backing,
lost their graphics layer, or resized to zero during the transition.
All states throw errors in `InspectorLayerTreeAgent::requestContent`.

The zero-size case is common because, during navigation, the new page's render 
tree initially creates
layers with zero dimensions before layout runs.

The error returned by the backend is handled by calling the callback to 
`snapshotForLayer()` with `null`
which is a case handled further down the call chain in 
`WI.Layers3DContentView.prototype._loadLayerTexture()`.

This is only an issue in Engineering / Debug builds of Web Inspector where
`WI.reportInternalError(error)` surfaces the exception. In release builds, the 
`null` case is silently handled.
This patch changes the backend to return an empty string instead of throwing an 
error for zero-size layers
given how common the case is during page navigation and that zero-sized layers 
aren't really an error state.

The issue itself is transient because during reload/navigation, more layer tree 
change events are dispatched.

The compositing update that resized layers to zero isn't the last one. When the 
new page finishes loading and layout,
`RenderLayerCompositor::updateCompositingLayers` runs again, firing another 
event.

The failed snapshot from the transitional state just results in 
`callback(null)` in
`WI.Layers3DContentView.prototype._loadLayerTexture`, which means no texture is 
applied to that layer group.
Then, the next successful cycle replaces it with the correct textured mesh.

The zero-size layer error only hits during the intermediate state. The final 
stable state always produces a clean pass.

* Source/WebCore/inspector/agents/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::requestContent):
* Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js:
(WI.LayerTreeManager.prototype.snapshotForLayer):

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



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

Reply via email to