mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user