Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point errors calculating keyframe end progress #2508

Open
aembury7 opened this issue Dec 5, 2024 · 2 comments
Open

Floating point errors calculating keyframe end progress #2508

aembury7 opened this issue Dec 5, 2024 · 2 comments

Comments

@aembury7
Copy link

aembury7 commented Dec 5, 2024

Which Version of Lottie are you using?

Lottie 4.4.2

Expected Behavior

Changing between markers without flickering/dropping frames.

To reproduce this issue, simply change from marker "voiceLoop1" to "voiceLoop2" to "voiceLoop3" in a random order.

Please note this was updated in Android here.

Actual Behavior

This is a bug that leads to the wrong keyframe being used due to a floating point rounding error.
Given specific composition start frames and the existing floating point rounding, you could wind up with the following situation:

Keyframe 1 has an endFrame of 48 and an endProgress of 0.095051385
Keyframe 2 has a startFrame of 48 and a startProgress of 0.09505139

Animation JSON

Please find attached.
DemoVoice.json

@calda
Copy link
Member

calda commented Dec 5, 2024

When I test this animation locally, cycling randomly through the three markers, I don't see any flickering:

Screen.Recording.2024-12-05.at.9.55.02.AM.mov

For us to investigate further you'd need to share a sample Xcode project that demonstrates the flickering issue.

For reference, this is how I set up the looping:

.playbackMode(playbackMode)
.animationDidFinish { completed in
  marker = ["voiceLoop1", "voiceLoop2", "voiceLoop3"].filter { $0 != marker }.randomElement()!
}
@State private var marker = ["voiceLoop1", "voiceLoop2", "voiceLoop3"].randomElement()!

private var playbackMode: LottiePlaybackMode {
  .playing(.marker(marker, loopMode: .playOnce))
}

Copy link

This issue is stale because it is marked "can't reproduce" and has had no activity in the past week. Please comment with additional information, or this issue will be closed due to inactivity in one week.

@github-actions github-actions bot added the Stale label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants