CALayerTreeCoordinator allocates a new CAContext on resize to eliminate flicker

提交: acca2e2d | 2026-05-04 17:12:23

← 返回列表

CALayerTreeCoordinator allocates a new CAContext on resize to eliminate flicker

Moderate
提交哈希: acca2e2d3d5cbadec69d34c55bc6b33079708b6f
提交时间: 2026-05-04 17:12:23
影响等级: Moderate
生成工具: chromium-watcher
上游审核链接: 查看上游审核 🔗

📋 摘要

This commit modifies CALayerTreeCoordinator in the GPU process to create a new CAContext on window resize instead of reusing the existing one. By using CAContext's fence port API, the old CAContext is "frozen" until the new one is ready, preventing white-flash flickering caused by lack of synchronization between GPU and browser processes during resize. On the browser side (DisplayCALayerTree), new logic holds onto fence mach ports (up to 4) to ensure old frame content isn't released prematurely. The gfx::CALayerParams struct and remote_layer_api.h also gain new fence port fields and API declarations.

🎯 影响分析

This change has moderate impact on WebView2Mac. DisplayCALayerTree is a critical component in the WebView2Mac rendering chain — it resides in the WebView2 host process (App Shim side) and is called by NativeWidgetNSWindowBridge::SetCALayerParams() to display frames from the GPU process. Specific impacts:

1. DisplayCALayerTree gains a new ca_context_fence_mach_ports_ member (circular_deque) to hold fence ports during resize, preventing flicker. This logic will automatically enter WebView2Mac's rendering path when the Chromium roll lands in Edge.
2. The gfx::CALayerParams struct gains a new ca_context_fence_mach_port field (ScopedMachSendRight), affecting how this struct is serialized via Mojo from the browser process to the host process. Corresponding mojom traits may also need updating.
3. This change does NOT modify Remote Cocoa Mojo interface definitions (NativeWidgetNSWindow mojom is untouched), so no WebView2-specific adaptation code is required.
4. The overall effect is improved visual experience during WebView2Mac window resize (reduced flickering). However, attention should be paid to CALayerParams struct changes and their Mojo serialization compatibility during Chromium roll.

受影响的类:

ui::DisplayCALayerTree ui::CALayerTreeCoordinator gfx::CALayerParams