rive-app / rive-app/rive-react-native

When using `.pause()`, then `.play()` on iOS, animation won't re-start

Open
#307 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
783
Forks
81
Avg merge
3d 6h
Merged PRs (30d)
3

Description

Description

<-- A clear and concise description of what the problem is. -->
When I was testing my app on iOS, then play/pause button that triggers the animation to restart isn't restarting, it just stays on the paused state once I press it to pause.

Provide a Repro
  const riveRef = useRef<RiveRef>(null);

  function onPressPause() {
    setTimer(TimerState.Paused);
    riveRef.current?.pause();
  }

  function onPressPlay() {
    setTimer(TimerState.Running);
    riveRef.current?.play();
  }

return (
  <>
        <Rive
          fit={Fit.Cover}
          ref={riveRef}
          url={RIVE_ASSET_URL}
          artboardName={`AT_${animalType.toUpperCase()}`}
          stateMachineName={INITIAL_STATE_MACHINE}
          style={{ width: "100%", height: "100%" }}
          autoplay
          onPlay={(animationName, isStateMachine) => {
            console.log(
              "onPlay: ",
              animationName,
              "isStateMachine: ",
              isStateMachine
            );
          }}
          onPause={(animationName, isStateMachine) => {
            console.log(
              "onPause:",
              animationName,
              "isStateMachine: ",
              isStateMachine
            );
          }}
          onError={(riveError: RNRiveError) => {
            console.error({ riveError });
          }}
        />

{timer === TimerState.Paused ? (
          <TimerButton
            onPress={onPressPlay}
            title="Resume"
            accessibilityLabel="Resume timer"
            icon={<PlayIcon />}
          />
        ) : (
          <TimerButton
            onPress={onPressPause}
            title="Pause"
            accessibilityLabel="Pause the timer"
            icon={<PauseIcon />}
            isDisabled={timer === TimerState.Finished}
          />
        )}
 </>
)
Expected behavior

The animation should start playing again once I evoke the .play() method.

Screenshots

Video of the issue

Device & Versions (please complete the following information)
  • Device: iOS Emulator
  • OS: iOS 18.1
  • NPM Version: 10.9.2 (but I'm using Yarn, and it's the 4.7.0 v)
Additional context

On Android, this works as expected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TypeScript reproduction's Rive ref calls to compare .pause() and .play() behavior on iOS versus Android. Trace the Rive component and playback entry points, then verify that invoking .play() after .pause() resumes the animation and preserves the expected callbacks.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, react-native, typescript
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.