Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 209e271d944ef2a3758bc25ca8ff8ab9bd149155
https://github.com/WebKit/WebKit/commit/209e271d944ef2a3758bc25ca8ff8ab9bd149155
Author: Ben Nham <[email protected]>
Date: 2026-08-28 (Fri, 28 Aug 2026)
Changed paths:
M Source/WebCore/platform/PlatformScreen.cpp
M Source/WebCore/platform/PlatformScreen.h
M Source/WebCore/platform/mac/PlatformScreenMac.mm
M Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
M Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp
M Source/WebKit/UIProcess/GPU/GPUProcessProxy.h
M Source/WebKit/UIProcess/WebProcessPool.cpp
M Source/WebKit/UIProcess/WebProcessPool.h
M Tools/TestWebKitAPI/PlatformCocoa.cmake
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebCore/cocoa/PlatformScreenTests.mm
Log Message:
-----------
Move some part of collectScreenProperties to a background thread
https://bugs.webkit.org/show_bug.cgi?id=322756
rdar://184130213
Reviewed by Simon Fraser.
We are getting hang logs showing that some part of collectScreenProperties (the
call to
`+preferredVideoRangeForDisplays:`) ends up in a sync IPC to WindowServer that
can sometimes block
the main thread of the UIProcess for multiple seconds.
To fix this, this patch adds a collectScreenPropertiesAsync function, which
moves just the HDR state
collection for a display to a background thread. (Note that I considered just
running all of
collectScreenProperties on a background thread, but after inspection it seems
like some NSScreen
methods aren't meant to be called off the main thread.)
In addition, WebProcessPool now caches the last screen properties state and
uses it on the
WebProcess creation path. This removes a sync IPC from the WebProcess creation
path.
Test: Tools/TestWebKitAPI/Tests/WebCore/cocoa/PlatformScreenTests.mm
* Source/WebCore/platform/PlatformScreen.cpp:
(WebCore::collectScreenPropertiesAsync):
* Source/WebCore/platform/PlatformScreen.h:
* Source/WebCore/platform/mac/PlatformScreenMac.mm:
(WebCore::collectHDRStateForDisplay):
(WebCore::collectHDRState):
(WebCore::collectScreenPropertiesExceptForHDRState):
(WebCore::collectScreenProperties):
(WebCore::collectScreenPropertiesAsync):
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
(WebKit::WebProcessPool::screenPropertiesUpdateTimerFired):
(WebKit::WebProcessPool::didCollectScreenProperties):
(WebKit::WebProcessPool::applyEDRSuppressionIfNeeded):
(WebKit::WebProcessPool::cachedScreenProperties):
* Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::updateScreenPropertiesIfNeeded):
* Source/WebKit/UIProcess/GPU/GPUProcessProxy.h:
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureGPUProcess):
(WebKit::WebProcessPool::createWebPage):
* Source/WebKit/UIProcess/WebProcessPool.h:
* Tools/TestWebKitAPI/PlatformCocoa.cmake:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/PlatformScreenTests.mm: Added.
(TestWebKitAPI::TEST(PlatformScreen, CollectScreenPropertiesAsync)):
Canonical link: https://commits.webkit.org/320060@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications