Bug 252668

Summary: Calling FontCascade::glyphDataForCharacter triggers unexpected change in font loading behavior
Product: WebKit Reporter: zalan <zalan>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ap, bfulgham, mmaxfield, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=253207
Attachments:
Description Flags
Early access
none
Delayed access
none
WebInspector timelines none

zalan
Reported 2023-02-21 09:01:12 PST
fast/text/font-promises-gc.html imported/w3c/web-platform-tests/css/css-fonts/fallback-remote-to-data-url.html imported/w3c/web-platform-tests/css/css-fonts/font-display/font-display-failure-fallback.html they fail/pass depending on whether we issue a call to FontCascade::glyphDataForCharacter in RenderText::styleDidChange (see canUseSimplifiedTextMeasuring) or not.
Attachments
Early access (312.09 KB, image/png)
2023-03-17 06:39 PDT, zalan
no flags
Delayed access (439.19 KB, image/png)
2023-03-17 06:39 PDT, zalan
no flags
WebInspector timelines (888.64 KB, application/zip)
2023-03-17 06:40 PDT, zalan
no flags
zalan
Comment 1 2023-02-22 07:00:35 PST
it looks like imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-012.html also sensitive to this "first glyph call" (fails in WKTR, works fine when loading in MiniBrowser)
Radar WebKit Bug Importer
Comment 2 2023-02-28 09:02:26 PST
zalan
Comment 3 2023-03-17 06:39:11 PDT
Created attachment 465475 [details] Early access Running imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-012.html with glyph data being access at tree construction time.
zalan
Comment 4 2023-03-17 06:39:52 PDT
Created attachment 465476 [details] Delayed access Running imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-012.html with glyph data being access right before layout.
zalan
Comment 5 2023-03-17 06:40:33 PDT
Created attachment 465477 [details] WebInspector timelines
zalan
Comment 6 2023-03-17 06:55:34 PDT
Timeline recording shows that 1. reading glyph data triggers font loading 2. delayed reading may cause intermediate rendering with blank glyphs
zalan
Comment 7 2023-03-17 08:31:55 PDT
stacktrace for font loading (initiated by accessing glyph data) * frame #0: 0x000000014af5130c WebCore`WebCore::DocumentFontLoader::beginLoadingFontSoon(this=0x000000010f0f12b0, font=0x000000010f06df00) at DocumentFontLoader.cpp:66:9 frame #1: 0x000000014af51284 WebCore`WebCore::Document::beginLoadingFontSoon(this={ origin = , url = , inMainFrame = Detached, backForwardCacheState = NotInBackForwardCache }, request=0x000000010f0f39c0) at Document.cpp:3203:19 frame #2: 0x000000014aa9545c WebCore`WebCore::CSSFontFaceSource::load(this=0x000000010f126c00, document={ origin = , url = , inMainFrame = Detached, backForwardCacheState = None }) at CSSFontFaceSource.cpp:159:22 frame #3: 0x000000014aa58260 WebCore`WebCore::CSSFontFace::pump(this=0x000000010f052220, policy=Allow) at CSSFontFace.cpp:644:25 frame #4: 0x000000014aa59b34 WebCore`WebCore::CSSFontFace::font(this=0x000000010f052220, fontDescription=0x000000010f0cf628, syntheticBold=false, syntheticItalic=false, policy=Allow, fontPaletteValues=0x000000010f0cf6d0, fontFeatureValues=RefPtr<WebCore::FontFeatureValues, WTF::RawPtrTraits<WebCore::FontFeatureValues>, WTF::DefaultRefDerefTraits<WebCore::FontFeatureValues> > @ 0x000000016f931780) at CSSFontFace.cpp:708:25 frame #5: 0x000000014ab08f34 WebCore`WebCore::CSSFontAccessor::font(this=0x000000010f0cf600, policy=Allow) const at CSSSegmentedFontFace.cpp:72:45 frame #6: 0x000000014c3275ec WebCore`WebCore::FontRanges::Range::font(this=0x000000010f0a9528, policy=Allow) const at FontRanges.cpp:38:28 frame #7: 0x000000014c2fa8d8 WebCore`WebCore::glyphPageFromFontRanges(pageNumber=7, fontRanges=0x000000010f0a9518) at FontCascadeFonts.cpp:465:26 frame #8: 0x000000014c2f1290 WebCore`WebCore::FontCascadeFonts::glyphDataForCharacter(this=0x000000010f0a9500, c=120, description=0x000000010f0a23b0, variant=NormalVariant) at FontCascadeFonts.cpp:507:38 frame #9: 0x000000014c2f0fb4 WebCore`WebCore::FontCascade::glyphDataForCharacter(this=0x000000010f0a23a0, c=120, mirror=false, variant=NormalVariant) const at FontCascade.cpp:333:21 frame #10: 0x000000014cb6a9d0 WebCore`WebCore::initiateFontLoadingByAccessingGlyphData(textContent={ length = 1, contents = 'x' }, fontCascade=0x000000010f0a23a0) at RenderText.cpp:256:21 frame #11: 0x000000014cb6a74c WebCore`WebCore::RenderText::styleDidChange(this=0x0000000111003af0, diff=Equal, oldStyle=0x0000000000000000) at RenderText.cpp:272:9 frame #12: 0x000000014c9b1158 WebCore`WebCore::RenderElement::didAttachChild(this=0x0000000111003400, child=0x0000000111003af0, (null)=0x0000000000000000) at RenderElement.cpp:547:37 frame #13: 0x000000014cd5fdac WebCore`WebCore::RenderTreeBuilder::attachToRenderElement(this=0x000000016f934c38, parent=0x0000000111003400, child=nullptr, beforeChild=0x0000000000000000) at RenderTreeBuilder.cpp:421:12 frame #14: 0x000000014cd60144 WebCore`WebCore::RenderTreeBuilder::Inline::attachIgnoringContinuation(this=0x000000010f149910, parent=0x0000000111003400, child=nullptr, beforeChild=0x0000000000000000) at RenderTreeBuilderInline.cpp:194:15 frame #15: 0x000000014cd5fbb8 WebCore`WebCore::RenderTreeBuilder::Inline::attach(this=0x000000010f149910, parent=0x0000000111003400, child=nullptr, beforeChild=0x0000000000000000) at RenderTreeBuilderInline.cpp:117:5 frame #16: 0x000000014cd5edd4 WebCore`WebCore::RenderTreeBuilder::attachInternal(this=0x000000016f934c38, parent=0x0000000111003400, child=nullptr, beforeChild=0x0000000000000000) at RenderTreeBuilder.cpp:330:25 frame #17: 0x000000014cd5e220 WebCore`WebCore::RenderTreeBuilder::attach(this=0x000000016f934c38, parent=0x0000000111003400, child=nullptr, beforeChild=0x0000000000000000) at RenderTreeBuilder.cpp:179:5 frame #18: 0x000000014cd7c600 WebCore`WebCore::RenderTreeUpdater::createTextRenderer(this=0x000000016f934c10, textNode=0x0000000111009800, textUpdate=0x0000000000000000) at RenderTreeUpdater.cpp:504:15
Note You need to log in before you can comment on or make changes to this bug.