Repository navigation
Conversation
mfazekas
force-pushed
the
feat/offscreen-behavior
branch
from
July 31, 2026 06:01
cf392a9 to
4466bfd
Compare
Views covered by UI they cannot detect (a screen pushed with a JS stack navigator, a Modal, an opaque sibling) stay attached and shown, so they keep advancing and drawing. renderEnabled={false} skips draws while the state machine keeps advancing (Android only); 'pause' also stops advancing and composes with the pause()/play() ref methods.
mfazekas
force-pushed
the
feat/offscreen-behavior
branch
from
November 19, 2026 10:42
4466bfd to
f71bdb9
Compare
mfazekas
marked this pull request as draft
November 19, 2026 13:22
mfazekas
added a commit
that referenced
this pull request
Nov 20, 2026
A screen pushed with `@react-navigation/stack` (with inactive screens
kept attached) leaves the screen underneath attached and shown on
Android, so looping Rive views on it keep advancing and drawing at full
rate. The view can't detect that on its own, so this adds a `paused?:
boolean` prop the app can drive, e.g. `paused={!isFocused}`.
`paused` stops advancing and drawing on the new backends;
`paused={false}` resumes where it left off (the frame timebase is reset
like `pause()` does). It combines with the ref: the view runs only when
neither the prop nor `pause()` has paused it, so `paused` wins over
`play()`, unpausing doesn't undo an earlier `pause()`, and
`autoPlay={false}` still waits for `play()`. It survives
reloads/reconfigures, and a view mounted paused still draws its first
frame and resolves `awaitViewReady()`. Legacy backends accept and ignore
it. On Android it's one main-thread flag folded into the existing
advancing/has-work check; on iOS it's kept apart from `isPaused` and
OR-ed in wherever `RiveUIView.isPaused` is written.
Measured on a Pixel 6 emulator with looping views under a stack push,
process CPU as % of one core: main 43–58% with 61 advances/s while
covered; this PR with `paused` off 48–75%, with `paused={!isFocused}`
1–2.5% and 0 advances/s. Playback resumes on going back. The
`PausedCovered` example page reproduces it with a live advances/s
counter. `example/__tests__/paused-prop.harness.tsx` passes on Android
(Pixel 6 emulator) and iOS (iOS 26.5 simulator), along with the existing
playback suites.
Supersedes #362 (`renderEnabled`); its skip-draws mode (`false`) is
parked.
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.
Parked in favor of #472, which adds only a
paused?: booleanprop. That covers the covered-screen case with the same effect as'pause'here, works the same on both platforms, and avoids theboolean | stringprop. This PR is kept for reference for its Android-only skip-draws mode (false) and will likely be closed.Adds
renderEnabled?: boolean | 'pause'toRiveView, for views covered by UI they cannot detect. A customer's home screen has two looping Rive views; pushing a screen over it with@react-navigation/stackleaves the home screen attached and shown on Android, so both views kept advancing and drawing (168% CPU on their device).renderEnabled={isFocused ? true : 'pause'}brought that down to 16% and resumed fine.true(default): render normally.false: skip draws while the state machine keeps advancing, so events and data binding stay live. Android only; on iOS the runtime couples advancing and drawing, so it behaves liketrue.'pause': stop advancing and drawing. It composes with thepause()/play()ref methods rather than overwriting their state.On Android this is built into the current on-demand frame loop: a paused mode counts as no work, so no frame callbacks run while covered, and re-enabling forces one redraw.
offscreenBehaviormoved to #471 (parked). It only reacts to scrolled-out or hidden views, and that didn't help here (169%): a covering screen or sibling leavesisShown/getGlobalVisibleRecttrue. rive-android also has no equivalent.The new example page "renderEnabled on a covered screen" reproduces it: two looping views under a JS stack push (inactive screens kept attached) or an opaque sibling, with a live advances/s counter. Process CPU on a Pixel 6 emulator (release, % of one core, 3×8s samples, covered by the stack push):
true: 43–77%, 61 advances/sfalse: 3–11%, 61 advances/s'pause': ~1%, 0 advances/sGoing back resumes at 61 advances/s in every mode. With the ref
pause()active, uncovering keeps the view paused untilplay(). Emulator numbers vary between runs, so thetruerows of main and this PR overlap rather than differ.