Closed Bug 2076646 Opened 1 month ago Closed 1 month ago

Some text shadows appear darker than others when `layout.disable-pixel-alignment = true`

Categories

(Core :: Graphics: WebRender, defect, P3)

x86_64
Windows 11
defect

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: 6k64x4ma, Assigned: gw)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 1 external file)

Attached file testcase.html —

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:158.0) Gecko/20100101 Firefox/158.0

Steps to reproduce

Load the attached file.

Actual results

Some text shadows appear darker than others when Windows scaling is set to 125% or 150%.
When it's at 100%, the shadow intensity is consistent.

Expected results

It would be good if the shadow intensity were consistent.

Regression window with layout.disable-pixel-alignment = true and layout.scroll.disable-pixel-alignment = true:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=8cf3b09b71da83703e0b0285ff6d81b01ddc3c1d&tochange=bfc6a1e723c3790d435849dd8864f799b2ff38a3

Attached image image.webp —
OS: Unspecified → Windows 11
Hardware: Unspecified → x86_64
Version: Other Branch → Trunk

The severity field is not set for this bug.
:gw, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(mozilla)

Hackbot couldn't reproduce this automatically because it's a visual issue that only appears at fractional DPI, so it needs manual attention. layout.disable-pixel-alignment now defaults to true in mozilla-central, so this is a supported configuration.

Likely cause, from reading the code (not verified): with pixel alignment disabled, the text baseline is no longer pre-snapped (nsLayoutUtils::GetMaybeSnappedBaselineY). WebRender then snaps the original glyphs and their text-shadow copy to device pixels separately:

  • The original text is positioned in device mode (TextRunTemplate::request_resources, prim_store/text_run.rs).
  • The blurred shadow copy is translated by the shadow offset in shadow_copy_of_item (webrender_api/src/display_list.rs) and is snapped in local-raster mode.

At 125% scaling, a 1px offset is 1.25 device px. Depending on each line's fractional top, the effective text-to-shadow offset therefore comes out as 1 or 2 device px, and the lines with 2px look darker. One possible fix: snap the shadow pen as snapped(original pen) + rounded(device offset), not snapping the offset position on its own.


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.

Severity: -- → S3
Priority: -- → P3

Looks like a snapping issue.

Blocks: wr-snap

At fractional device scales the shadow offset is fractional in layout space,
and the shadow copy's glyphs were snapped independently of the original's, so
the visible offset flipped between whole pixels with the text's sub-pixel
phase. Carry the shadow offset on the copied text item and place each shadow
glyph at the original pen plus the offset rounded on the pixel-snapped axes.

Assignee: nobody → mozilla
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(mozilla)
Attachment #9655545 - Attachment description: Bug 2076646 - Snap text shadow copies relative to the original glyphs. → Bug 2076646 - Snap shadow contents relative to the content they shadow.
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
QA Whiteboard: [qa-triage-done-c161/b160]
Regressions: 2092300
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: