Bug 237330 - A text node longer than 65,535 characters following another text node is invisible in a scrolling context
Summary: A text node longer than 65,535 characters following another text node is invi...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari Technology Preview
Hardware: Mac (Apple Silicon) macOS 12
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-01 09:38 PST by Jed Fox
Modified: 2022-03-03 09:57 PST (History)
13 users (show)

See Also:


Attachments
HTML file with sample code that does and does not trigger the bug (385.06 KB, text/html)
2022-03-01 09:38 PST, Jed Fox
no flags Details
Test reduction (just a slight iteration on the test above) (64.14 KB, text/html)
2022-03-01 16:01 PST, zalan
no flags Details
Patch (131.61 KB, patch)
2022-03-03 08:34 PST, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jed Fox 2022-03-01 09:38:28 PST
Created attachment 453507 [details]
HTML file with sample code that does and does not trigger the bug

I’ve narrowed the reproduction down to the following specific requirements:

- A parent node must have `overflow: auto` (not necessarily the immediate parent of the text node)
- The text node must not be the first node on its line (taking word wrapping into account)
- The text node must have at least 65,536 characters (I tested with the ASCII 0, although it seems that other characters can be present)

Encountered in the wild: https://github.com/facebook/jsx/pull/136#issuecomment-1055288199

Reproduced on STP Release 140 (Safari 15.4, WebKit 17614.1.1.5) and WebKit r290647 on macOS 12.2.1 (21D62)
Comment 1 Radar WebKit Bug Importer 2022-03-01 15:33:51 PST
<rdar://problem/89645522>
Comment 2 zalan 2022-03-01 16:01:19 PST
Created attachment 453545 [details]
Test reduction (just a slight iteration on the test above)
Comment 3 zalan 2022-03-01 16:02:58 PST
This is most likely caused by our 64K RenderText split.
Comment 4 zalan 2022-03-01 16:10:34 PST
Yeah, it must be it. If some of the characters are wrapped inside an inline box e.g. <span>0</span> (fragmenting the text content, producing multiple renderers), the content shows up fine.
Comment 5 zalan 2022-03-02 11:20:57 PST
Apparently LegacyInlineTextBox can't hold more than 65535 characters.

unsigned short m_len { 0 };

arithmetic overflow causes m_len -> 0 and the rest of the layout believes it's a blank box.
Comment 6 zalan 2022-03-03 08:34:05 PST
Created attachment 453745 [details]
Patch
Comment 7 EWS 2022-03-03 09:57:47 PST
Committed r290782 (248026@main): <https://commits.webkit.org/248026@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453745 [details].