Closed Bug 1873708 Opened 1 years ago Closed 1 years ago

Canvas fillText+Filter - Over-Clipping on mixed ASCII+Emojis

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 121
defect

Tracking

()

VERIFIED FIXED
123 Branch
Tracking Status
firefox123 --- verified
firefox124 --- verified

People

(Reporter: tomxor, Assigned: jfkthame)

References

Details

Attachments

(4 files, 1 obsolete file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0

Steps to reproduce:

Set up a canvas and 2d context. Add any filter to the context, use fillText with a string containing a combination of ASCII and unicode emojis. Ensure the leftmost and rightmost characters are emojis to make the incorrect clipping more obvious.

Actual results:

The rendered text is clipped to a bounding box containing only the ASCII characters. The emoji characters will still be rendered but clipped on both the x and y.

Expected results:

The full text should be visible.

Note: This does not occur if all of the characters are emojis. It also doesn't seem to generalise to any non-ASCII code point, and is not even specific to UTF-16 surrogate pairs some of which can be used without triggering this bug. It seems to be specific to emoji characters (although I have not tested all of them), perhaps because they are not simple vectors outlines.

Upload mangled the unicode, this one has unicode escapes.

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: Canvas2D' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Graphics: Canvas2D
Product: Firefox → Core
Attachment #9371795 - Attachment is obsolete: true

Confirmed on my M1 Mac. Requesting a Pernosco session, in case it helps. NI'ing triage owner.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(lsalzman)
Keywords: bugmon
Flags: needinfo?(lsalzman) → needinfo?(jfkthame)

Erich, unfortunately bugmon can only be used to record pernosco sessions for bugs that trigger a crash or fatal assertion.

On macOS, there's a less severe form of this issue: I'm seeing the filtered emoji glyphs being clipped at the baseline, but at least they're not clipped at the top or sides.

In both cases, I assume the cause is that our attempt to get glyph bounds (as a basis for the size of the surface used during the filtering operation) is failing for bitmap glyphs.

Flags: needinfo?(jfkthame)

(In reply to Jonathan Kew [:jfkthame] from comment #5)

In both cases, I assume the cause is that our attempt to get glyph bounds (as a basis for the size of the surface used during the filtering operation) is failing for bitmap glyphs.

Huh, in the Linux case it's the Twemoji Mozilla font that's not getting proper bounds. I guess that's because it doesn't have fallback monochrome glyphs at the nominal glyph IDs; it only has the color layers, and FreeType isn't considering those when we retrieve the bounds in gfxFT2FontBase::GetFTGlyphExtents.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

Nice work, that was quick!

Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c6b21b2db104 patch 1 - Synthesize fallback glyph extents for color glyphs if FreeType returned empty bounds, to avoid clipped rendering. r=gfx-reviewers,aosmond https://hg.mozilla.org/integration/autoland/rev/0dc21611ff97 patch 2 - Try to avoid clipping emoji glyphs on macOS when applying canvas filters. r=gfx-reviewers,aosmond https://hg.mozilla.org/integration/autoland/rev/387701b0f788 Add a simple reftest based on the reporter's example. r=gfx-reviewers,jrmuizel
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f7d8b68a1368 patch 1 - Synthesize fallback glyph extents for color glyphs if FreeType returned empty bounds, to avoid clipped rendering. r=gfx-reviewers,aosmond https://hg.mozilla.org/integration/autoland/rev/8749d9a52c79 patch 2 - Try to avoid clipping emoji glyphs on macOS when applying canvas filters. r=gfx-reviewers,aosmond https://hg.mozilla.org/integration/autoland/rev/abab19c548b5 Add a simple reftest based on the reporter's example. r=gfx-reviewers,jrmuizel
Status: ASSIGNED → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
Target Milestone: --- → 123 Branch
See Also: → 1877286
Duplicate of this bug: 1877286

I was able to reproduce the issue on Firefox 123.0a1 (2024-01-08) on macOS 14.3.1 by using the provided file in Comment 1.

The issue is fixed on Firefox 123.0b9 and Firefox 124.0a1 (2024-02-11). Tests were performed on macOS 14.3.1, Windows 11 and Ubuntu 22.04.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Flags: needinfo?(jfkthame)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: