Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 445ef0dbfc62962d2a1f1badfd0cfd626ec8d996
      
https://github.com/WebKit/WebKit/commit/445ef0dbfc62962d2a1f1badfd0cfd626ec8d996
  Author: Aditya Keerthi <[email protected]>
  Date:   2026-09-24 (Thu, 24 Sep 2026)

  Changed paths:
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/platform/PlatformScreen.h
    M Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
    M Source/WebCore/platform/ios/PlatformScreenIOS.mm
    M Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebProcessPool.h
    M Source/WebKit/UIProcess/ios/WKContentView.mm
    M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

  Log Message:
  -----------
  HDR images are not supported on the iPhone Duo's inner screen
https://bugs.webkit.org/show_bug.cgi?id=324893
rdar://188123007

Reviewed by Mike Wyrzykowski.

On iOS, display IDs are currently generated per-page using the page ID, via
WebPageProxy::generateDisplayIDFromPageID(). However, those IDs do not
correspond to a real display, and do not match the sequential IDs assigned to
each `UIScreen` in `collectScreenProperties()`. As a result, no lookup into
the screen data map could ever succeed for a page's display ID, and every
screen property query (HDR support, EDR headroom, EDR suppression) falls back
to the primary screen. On the iPhone Duo, this is the outer screen. The outer
screen is inactive when the inner screen is active, which means the EDR headroom
for the primary display is reduced. Since that is the only value reported, HDR
images do not render as HDR on the inner screen.

Fix by assigning display IDs from a registry keyed by `UIScreen`,and use it
everywhere a display ID is produced on iOS. Screen property queries now honor
the display ID they are given rather than always consulting the primary screen.
Since EDR headroom is a per-display property, `WebProcessPool` now tracks it
per display, and observes `UIScreen` connection notifications so that screen
properties are republished, and retired display IDs are dropped, when the set
of displays changes.

* Source/WebCore/page/Page.cpp:
(WebCore::Page::windowScreenDidChange):

Update the page's EDR headroom when it moves to a new display, since the new
display's headroom may differ from the previous one's.

* Source/WebCore/platform/PlatformScreen.h:

Export displayID(UIScreen *) and `invalidateDisplayID(UIScreen *)` so that 
WebKit
can map a `UIScreen` onto the display ID used in `ScreenProperties`.

* Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setNeedsDisplayIfEDRHeadroomExceeds):

When the EDR headroom changes, 
`LocalFrameView::setDescendantsNeedUpdateBackingAndHierarchyTraversal`
is called. However, dirtying the backing store doesn't change a layer property,
so nothing has requests a flush. Contary to the existing logic, a flush should
only be requested when there are no uncommitted changes, since a flush is needed
when EDR headroom exceeds a threshold. Requesting a flush when there are 
uncommitted
changes is redundant, since that is already done in 
`noteLayerPropertyChanged()`.

Also, do nothing when the layer is being destroyed.

Without this change, the used headroom does not update until the user scrolls 
the page.

* Source/WebCore/platform/ios/PlatformScreenIOS.mm:
(WebCore::screenToDisplayIDMap):

There is no stable identifier for a display accessible by public UIKit API.
Consequently, IDs are assigned when a `UIScreen` is first noted, and keyed by
pointer identity. Entries are removed by `invalidateDisplayID()` when a screen
disconnects.

(WebCore::displayID):

Returns the ID for a UIScreen, assigning a new one if the screen has not been
seen before. A null screen means the main screen. 0 is reserved to mean
"unknown display", so IDs start at 1, and IDs are never reused, so a retired ID
cannot come to name a different display.

The registry is only meaningful in the UI process, where 
`collectScreenProperties()`
runs; other processes receive the resulting IDs over IPC.

(WebCore::invalidateDisplayID):

Removes a disconnected screen from the map.

(WebCore::screenSupportsExtendedColor):
(WebCore::screenSupportsHighDynamicRange):
(WebCore::currentEDRHeadroomForDisplay):
(WebCore::maxEDRHeadroomForDisplay):
(WebCore::suppressEDRForDisplay):

Look up screen data for the display the caller asked about, instead of
unconditionally using the primary display.

(WebCore::collectScreenProperties):

Key the screen data map by `displayID(screen)` rather than by a local counter,
so the published IDs match the ones used pages in the web process.

This effectively addresses the existing FIXME regarding 
`generateDisplayIDFromPageID`.

* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::registerNotificationObservers):

Republish screen properties when a screen connects or disconnects. On 
disconnect,
remove the display's headroom entry before invalidating the ID, since
`displayID()` falls back to the main screen for a screen it no longer knows 
about.

Deprecated API is used here since the rest of the existing logic relies on
`UIScreen` machinery and is not scene-based.

(WebKit::WebProcessPool::unregisterNotificationObservers):

Remove the new observers.

(WebKit::WebProcessPool::didRefreshDisplay):

Track the current EDR headroom for every screen rather than only the primary
one, and republish screen properties if any display's headroom changed.

Deprecated API is used here since the rest of the existing logic relies on
`UIScreen` machinery and is not scene-based.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::swapToProvisionalPage):

Derive the display ID from the page client's screen rather than from the page 
ID.

* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebProcessPool.h:
* Source/WebKit/UIProcess/ios/WKContentView.mm:
(-[WKContentView _commonInitializationWithProcessPool:configuration:]):
(-[WKContentView _updateForScreen:]):

Report the display ID of the screen the view is actually on.

* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::generateDisplayIDFromPageID const): Deleted.

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



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

Reply via email to