fix(site): clamp SmoothText dtMs to prevent animation budget inflation (#23498)

After a long requestAnimationFrame pause (e.g. backgrounded tab), the
time delta can be very large, causing the character budget to spike and
bypass smooth rendering entirely. Clamp to 100ms.

Extracted from #23236.
This commit is contained in:
Mathias Fredriksson
2026-03-24 19:00:26 +02:00
committed by GitHub
parent e87ea1e0f5
commit 42fdd5ed2a
@@ -170,10 +170,14 @@ export class SmoothTextEngine {
* Advance the presentation clock by a timestep.
*/
tick(dtMs: number): number {
if (dtMs <= 0) {
if (dtMs <= 0 || Number.isNaN(dtMs)) {
return this.visibleLengthValue;
}
// Clamp to prevent charBudget inflation after long
// background periods where RAF was paused by the browser.
dtMs = Math.min(100, dtMs);
if (!this.isStreaming || this.bypassSmoothing) {
return this.visibleLengthValue;
}