Commit 0a1a06c
fix(requestIdleCallback): timeout not assigned at NativeIdleCallbacks (#57571)
Summary:
Fix #57570
Regression in `requestIdleCallback` introduced by:
- #51251
The `timeout` is never assigned, so it is never forwarded to `runtimeScheduler`.
Before the PR mentioned above, it was being assigned alongside `expirationTime`, but that was removed during the refactor.
Without this patch the task will keep running for up to `5 minutes` (default value).
NOTE: this fixes the `timeout` being dropped before it reaches `runtimeScheduler`. Idle tasks still resolve their timeout through `getResolvedTimeoutForIdleTask`, which adds the low priority timeout on top of a small custom value, so a sub-10s `timeout` still will not fire within a few milliseconds. Honoring an exact small timeout would change idle task scheduling semantics and is a separate discussion, out of scope for this fix.
## Changelog:
[GENERAL] [FIXED] - Fix requestIdleCallback timeout option being ignored
Pull Request resolved: #57571
Test Plan:
Before|After
--|--
<img width="1080" height="2424" alt="before" src="https://github.com/user-attachments/assets/1f5af3ee-a3cd-4bf1-b397-606c05ff3b52" />|<img width="1080" height="2424" alt="after" src="https://github.com/user-attachments/assets/8fb071ca-11ca-4cdb-bed3-009b1648ca8c" />
NOTE: no automated test is added because the fix only affects the idle task's scheduler expiration (with the timeout forwarded it resolves to ~10s via `getResolvedTimeoutForIdleTask`, without it the default 5min idle timeout). Distinguishing the two deterministically needs simulating competing scheduler load and advancing scheduler time by ~10s, which Fantom does not expose a clean hook for, and `didTimeout` is computed from a separate `expirationTime` that is set correctly even before the fix so it cannot tell them apart. The existing `requestIdleCallback-itest.js` suite tests ordering/priority for the same reason. Verified manually via the before/after repro above.
Reviewed By: cipolleschi
Differential Revision: D112988252
Pulled By: fabriziocucci
fbshipit-source-id: a2317275bc2faf163705e8926cff3b4c77942b011 parent 49f0db4 commit 0a1a06c
1 file changed
Lines changed: 1 addition & 0 deletions
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
0 commit comments