Repository navigation
Revert "Run requestIdleCallback polyfill after paint in 5ms slices of a 10ms per-frame budget" - #131
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A moderate active issue remains in src/requestidlecallback.ts: nullable options are rejected and Symbol timeout values are not synchronously coerced before scheduling.
1 open issue
What changed in this PR
This pull request reverts the frame-based requestIdleCallback scheduler from #129 and restores the simpler timer-based polyfill.
Changes:
- Restores
setTimeout-based callback scheduling with a 50 ms deadline. - Restores direct cancellation through
clearTimeout. - Removes scheduler-specific tests and retains basic API and deadline coverage.
| File | Summary | Review comments |
|---|---|---|
test/requestidlecallback.js |
Reduces coverage to basic API and deadline behavior. | No comments. |
src/requestidlecallback.ts |
Restores the timer-based idle callback implementation. | Moderate, 4 votes: Normalize nullable options and coerce timeout values before scheduling; current handling rejects null and defers Symbol errors. Moderate, 1 vote: Establish the idle deadline when the callback starts so delayed timer tasks receive a usable budget. |
Review effort: Lite (auto)
| schedule() | ||
| return id | ||
| const start = Date.now() | ||
| const timeout = options.timeout || 0 |
manuelpuyol
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Reverts #129. The source and tests go back exactly to their state before that merge (an empty diff against
b4f19bd^1).Why
#129 has no measurable benefit on real github.com pages, and it adds costs.
Benefit, measured. I ran logged-out React pages in Playwright WebKit 26.5: code view, an issues list and a repo home. Each run was about 20 s and included 45 inputs; figures are medians of 3 runs. These pages schedule 16 to 25 idle callbacks, with 4 to 8 ms of idle work in total and no single callback over 1 ms. At most 2 callbacks per run landed between an input and the next paint. Input-to-next-paint p90 was the same under the old polyfill and the new scheduler: 17/17 ms, 24/24 ms and 16/18 ms. The large gains appear only in synthetic workloads that keep the idle queue full.
Costs, measured in the same WebKit setup:
Not measured
Logged-in pages, real Safari, iOS, and slower devices. If a logged-in Safari profile shows idle callbacks regularly landing between inputs and paints, the scheduler from #129 plus #130 can be reconsidered.
Supersedes #130.