Skip to content

Add feature flag to keep Android timers running while the host is paused - #59371

Open
zeyap wants to merge 1 commit into
react:mainfrom
zeyap:export-D126948111
Open

zeyap wants to merge 1 commit into
react:mainfrom
zeyap:export-D126948111

Conversation

@zeyap

@zeyap zeyap commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary:
On Android, JavaTimerManager stops JS timers on onHostPause and only restarts them on onHostResume or while a headless JS task is active. When the app keeps using the JS runtime without a resumed React screen, pending setTimeouts and Promise-driven work that depends on them stall until a React screen resumes. On iOS, RCTTiming does not depend on host lifecycle: timers keep firing until the instance is invalidated.

Add keepTimersRunningWhileHostPausedAndroid (default false). When enabled, JavaTimerManager:

  • starts the timer frame callback when it is created, since the host may never resume;
  • stops timers only once the instance is destroyed (tracked by a new isDestroyed), instead of when the host is paused.

Changelog: [Internal]

Differential Revision: D126948111

Summary:
On Android, `JavaTimerManager` stops JS timers on `onHostPause` and only restarts them on `onHostResume` or while a headless JS task is active. When the app keeps using the JS runtime without a resumed React screen, pending `setTimeout`s and Promise-driven work that depends on them stall until a React screen resumes. On iOS, `RCTTiming` does not depend on host lifecycle: timers keep firing until the instance is invalidated.

Add `keepTimersRunningWhileHostPausedAndroid` (default `false`). When enabled, `JavaTimerManager`:
- starts the timer frame callback when it is created, since the host may never resume;
- stops timers only once the instance is destroyed (tracked by a new `isDestroyed`), instead of when the host is paused.

Changelog: [Internal]

Differential Revision: D126948111
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 22, 2026
@meta-codesync

meta-codesync Bot commented Oct 22, 2026

Copy link
Copy Markdown

@zeyap has exported this pull request. If you are a Meta employee, you can view the originating Diff in D126948111.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant