[PR #782] [CLOSED] Use a monotonic clock for renderer scheduling #1560

Closed
opened 2026-03-14 09:43:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/782
Author: @ermalos
Created: 3/5/2026
Status: Closed

Base: mainHead: fix/monotonic-renderer-scheduling


📝 Commits (1)

  • edbf3fa Use a monotonic clock for renderer scheduling

📊 Changes

2 files changed (+60 additions, -6 deletions)

View changed files

📝 packages/core/src/renderer.ts (+21 -6)
packages/core/src/tests/renderer.clock.test.ts (+39 -0)

📄 Description

Summary

  • replace Date.now()-based renderer scheduling with a monotonic clock
  • clamp negative elapsed times so backward clock jumps cannot stretch frame delays
  • add a regression test that simulates a backward clock jump during requestRender()

Why

On WSL, host/guest time corrections can jump the wall clock backwards. The renderer currently uses Date.now() to compute request/render delays, so a backward jump can turn a 16ms frame delay into a multi-second stall.

Testing

  • npx --yes bun@1.3.10 test packages/core/src/tests/renderer.clock.test.ts packages/core/src/tests/renderer.control.test.ts packages/core/src/tests/renderer.idle.test.ts

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/782 **Author:** [@ermalos](https://github.com/ermalos) **Created:** 3/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/monotonic-renderer-scheduling` --- ### 📝 Commits (1) - [`edbf3fa`](https://github.com/anomalyco/opentui/commit/edbf3fae7ac077a89b3fcdb8e678fb88e8d6db22) Use a monotonic clock for renderer scheduling ### 📊 Changes **2 files changed** (+60 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/renderer.ts` (+21 -6) ➕ `packages/core/src/tests/renderer.clock.test.ts` (+39 -0) </details> ### 📄 Description ## Summary - replace `Date.now()`-based renderer scheduling with a monotonic clock - clamp negative elapsed times so backward clock jumps cannot stretch frame delays - add a regression test that simulates a backward clock jump during `requestRender()` ## Why On WSL, host/guest time corrections can jump the wall clock backwards. The renderer currently uses `Date.now()` to compute request/render delays, so a backward jump can turn a 16ms frame delay into a multi-second stall. ## Testing - `npx --yes bun@1.3.10 test packages/core/src/tests/renderer.clock.test.ts packages/core/src/tests/renderer.control.test.ts packages/core/src/tests/renderer.idle.test.ts` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 09:43:18 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1560
No description provided.