Commit 0bca81a
authored
perf(chat): cap mobile memory with content-visibility on messages (#2391)
* perf(chat): cap mobile memory with content-visibility on messages
Long conversations render every message at once (no virtualization). On
mobile WebKit each tab renderer has a hard ~2 GB cap; a few hundred laid-out
messages plus paint backing stores exceeds it, so iOS Safari jetsam-kills the
tab and shows "A problem repeatedly occurred".
Add content-visibility:auto + contain-intrinsic-size to each message wrapper so
off-screen messages skip layout and paint, keeping peak renderer memory bounded.
content-visibility implies paint containment, so overflow-clip-margin is added to
keep the copy/retry/edit controls (which sit just below each message) painting.
* fix(chat): converge scroll-to-bottom for content-visibility messages
content-visibility:auto messages start at their contain-intrinsic-size estimate,
so the single initial scrollToBottom on conversation load/switch could land above
the true bottom once off-screen messages render at full height. On that path
spacerActive is 0, so ChatWindow's corrective ResizeObserver is inactive and the
action's own observer watches the h-full container that never resizes.
Add a bounded (max 5 frame) re-scroll on the instant scroll paths (initial mount
and conversation switch) that converges to the real bottom and bails early if the
user scrolls or we are already at the bottom. The smooth new-message path is
unchanged (ChatWindow's spacer observer already handles it).
Addresses PR review feedback.1 parent eb7d041 commit 0bca81a
2 files changed
Lines changed: 53 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
99 | 120 | | |
100 | 121 | | |
101 | 122 | | |
| |||
176 | 197 | | |
177 | 198 | | |
178 | 199 | | |
179 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
180 | 210 | | |
181 | 211 | | |
182 | 212 | | |
| |||
284 | 314 | | |
285 | 315 | | |
286 | 316 | | |
287 | | - | |
| 317 | + | |
288 | 318 | | |
289 | 319 | | |
290 | 320 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
555 | | - | |
| 555 | + | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| |||
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
689 | 708 | | |
690 | 709 | | |
691 | 710 | | |
| |||
0 commit comments