mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-24 20:45:56 +03:00
[GH-ISSUE #775] WSL2: TUI frame stalls when system clock jumps backward (Date.now/setTimeout scheduling) #980
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#980
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @turazashvili on GitHub (Mar 4, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/775
Summary
On WSL2, the TUI intermittently freezes for ~2–10 seconds while typing or scrolling.
This appears to happen when wall-clock time jumps backward (e.g. host/guest time sync interactions in WSL).
Renderer scheduling currently relies on
Date.now()+ delayedsetTimeout, which is sensitive to non-monotonic clock changes.Environment
@opentui/core)Observed behavior
Why this likely happens
Frame timing appears to use wall-clock (
Date.now) and one-shot delayedsetTimeout.If wall-clock moves backward, delay calculations can become effectively “too far in the future,” causing visible render stalls.
Local workaround that resolves it
I patched
@opentui/corelocally and the freezes disappeared by:performance.now()) for frame timingsetTimeout(..., delay)with a deadline loop:deadline = performance.now() + delaysetImmediate(check)untilperformance.now() >= deadline, then render/loopclearImmediate(...)Proposed source-level change (renderer)
In
packages/core/src/renderer.ts:performance.now()in:startRenderLoop()requestRender()loop()renderTimeouttype toReturnType<typeof setImmediate> | nullsetTimeoutframe scheduling with setImmediate + deadline checkclearImmediateconsistently forrenderTimeoutNotes
I can help validate a test/canary build on WSL2 once a patch is available.
@turazashvili commented on GitHub (Mar 8, 2026):
@simonklee is there anyone working on this? I saw closed PR. If this is relevant, I can push PR in the next couple days :)