Skip to content

Android is off by one when specifying frame to play #1121

@thevoiceless

Description

@thevoiceless

Description

The result of play(frame, frame) matches on iOS and web, but is off by +1 frame on Android.

Steps to Reproduce

  1. Create a barebones RN app
  2. Add lottie-react-native
  3. Update metro.config.js to include .lottie files
  4. Use play(frame, frame) to play a frame, using setTimeout() to ensure the animation is done loading

Expected behavior:
Same result on all platforms

Actual behavior:
iOS and web match, Android is off by +1

Example, playing frame 115 below on Android/web/iOS:
Screen Shot 2023-10-16 at 6 02 34 PM
Frame 116:
Screen Shot 2023-10-16 at 6 03 16 PM

Minimal reproduction

function App() {
  const animationRef = React.useRef<LottieView>(null);

  React.useEffect(() => {
    const timer = setTimeout(() => {
      animationRef?.current?.play(115, 115);
    }, 500);
    return () => clearTimeout(timer);
  }, []);

  return (
    <SafeAreaView>
      <LottieView
        ref={animationRef}
        source={require('./Lottie_OnOff_Microphone.lottie')}
        style={{width: 300, height: 300}}
      />
    </SafeAreaView>
  );
}

Lottie_OnOff_Microphone.lottie.zip

React Native Environment

Bare, 0.72.6

Lottie Version

6.3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions