Skip to content

[HDR] Gray background appears when switching from Safari tab overview to a tab with HDR images. #47211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025

Conversation

mattwoodrow
Copy link
Contributor

@mattwoodrow mattwoodrow commented Jun 25, 2025

e29aed8

[HDR] Gray background appears when switching from Safari tab overview to a tab with HDR images.
https://bugs.webkit.org/show_bug.cgi?id=294998
<rdar://154230589>

Reviewed by Simon Fraser and Mike Wyrzykowski.

Content painted by WebKit gets tonemapped at paint time, so we never want it to
be tonemapped again by the system.

Changes GraphicContext/RemoteLayerBackingStore to track the max EDR headroom
requested during painting, rather than just a bool of whether any draw exceeded
the available headroom.

Synchronize this value across to the UI process instead of the painted headroom,
and set it as the contentHeadroom so that the system knows what the intended
headroom is. Set CAToneMapModeNever for these layers, since tonemapping has
already been applied.

Also fixes a bug where GraphicsContextCG wouldn't call
CGContextSetEDRTargetHeadroom if the clamped headroom was 1, even if the image
had a higher source headroom.

* Source/WebCore/platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::maxRequestedEDRHeadroom const):
(WebCore::GraphicsContext::clearMaxEDRHeadrooms):
(WebCore::GraphicsContext::hasPaintedClampedEDRHeadroom const): Deleted.
(WebCore::GraphicsContext::clearMaxPaintedEDRHeadroom): Deleted.
* Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContextCG::drawNativeImageInternal):
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::encode const):
(WebKit::RemoteLayerBackingStoreProperties::dump const):
(WebKit::RemoteLayerBackingStore::setNeedsDisplay):
(WebKit::RemoteLayerBackingStore::setNeedsDisplayIfEDRHeadroomExceeds):
(WebKit::RemoteLayerBackingStore::setDelegatedContents):
(WebKit::RemoteLayerBackingStore::drawInContext):
(WebKit::RemoteLayerBackingStoreProperties::applyBackingStoreToLayer):
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTree.serialization.in:
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.mm:
(WebKit::RemoteLayerWithRemoteRenderingBackingStore::dump const):
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::screenPropertiesChanged):
* Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:
(WebKit::RemoteDisplayListRecorderProxy::drawNativeImageInternal):
* Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:

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

8bec538

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@mattwoodrow mattwoodrow requested a review from cdumez as a code owner June 25, 2025 23:17
@mattwoodrow mattwoodrow self-assigned this Jun 25, 2025
@mattwoodrow mattwoodrow added the Compositing Bugs related to layerization for transforms, video, scrolling etc label Jun 25, 2025
@smfr
Copy link
Contributor

smfr commented Jun 25, 2025

Changes GraphicContext/RemoteLayerBackingStore to track the max EDR headroom
requested during painted, rather than just a bool of whether any draw exceeded

During painting

Synchronize this value across instead, and set it as the contentHeadroom so that

across what?

@mattwoodrow mattwoodrow force-pushed the eng/dont-tonemap-ca branch from b58344e to 8bec538 Compare June 26, 2025 00:08
@mattwoodrow mattwoodrow added the merge-queue Applied to send a pull request to merge-queue label Jun 26, 2025
… to a tab with HDR images.

https://bugs.webkit.org/show_bug.cgi?id=294998
<rdar://154230589>

Reviewed by Simon Fraser and Mike Wyrzykowski.

Content painted by WebKit gets tonemapped at paint time, so we never want it to
be tonemapped again by the system.

Changes GraphicContext/RemoteLayerBackingStore to track the max EDR headroom
requested during painting, rather than just a bool of whether any draw exceeded
the available headroom.

Synchronize this value across to the UI process instead of the painted headroom,
and set it as the contentHeadroom so that the system knows what the intended
headroom is. Set CAToneMapModeNever for these layers, since tonemapping has
already been applied.

Also fixes a bug where GraphicsContextCG wouldn't call
CGContextSetEDRTargetHeadroom if the clamped headroom was 1, even if the image
had a higher source headroom.

* Source/WebCore/platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::maxRequestedEDRHeadroom const):
(WebCore::GraphicsContext::clearMaxEDRHeadrooms):
(WebCore::GraphicsContext::hasPaintedClampedEDRHeadroom const): Deleted.
(WebCore::GraphicsContext::clearMaxPaintedEDRHeadroom): Deleted.
* Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContextCG::drawNativeImageInternal):
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::encode const):
(WebKit::RemoteLayerBackingStoreProperties::dump const):
(WebKit::RemoteLayerBackingStore::setNeedsDisplay):
(WebKit::RemoteLayerBackingStore::setNeedsDisplayIfEDRHeadroomExceeds):
(WebKit::RemoteLayerBackingStore::setDelegatedContents):
(WebKit::RemoteLayerBackingStore::drawInContext):
(WebKit::RemoteLayerBackingStoreProperties::applyBackingStoreToLayer):
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTree.serialization.in:
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.mm:
(WebKit::RemoteLayerWithRemoteRenderingBackingStore::dump const):
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::screenPropertiesChanged):
* Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:
(WebKit::RemoteDisplayListRecorderProxy::drawNativeImageInternal):
* Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:

Canonical link: https://commits.webkit.org/296647@main
@webkit-commit-queue
Copy link
Collaborator

Committed 296647@main (e29aed8): https://commits.webkit.org/296647@main

Reviewed commits have been landed. Closing PR #47211 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit e29aed8 into WebKit:main Jun 26, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compositing Bugs related to layerization for transforms, video, scrolling etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants