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

Fix floating point errors calculating keyframe end progress #2588

Merged
merged 5 commits into from
Dec 4, 2024

Conversation

gpeal
Copy link
Collaborator

@gpeal gpeal commented Dec 4, 2024

This fixed a really tricky bug that led 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

The Keyframe.containsProgress check intentionally leaves the upper end of the range open to make it unambiguous that the progress on the boundary of two keyframes should use the latter one.

However, due to this floating point error, there was a gap and if the progress == the endProgress of the first keyframe, it wouldn't match either.

I was able to reconstruct this specific scenario with a unit test and confirmed that this fixed it. However, it is not impossible that there are other scenarios in which this could happen. However, I would rather avoid allocating doubles for everything which is more expensive unless we find a specific repro again

Copy link

github-actions bot commented Dec 4, 2024

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

Copy link

github-actions bot commented Dec 4, 2024

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

Copy link

github-actions bot commented Dec 4, 2024

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

Copy link

github-actions bot commented Dec 4, 2024

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

@gpeal gpeal changed the title Make Keyframe span check inclusive Fix floating point errors calculating keyframe end progress Dec 4, 2024
@gpeal gpeal merged commit 5273ec6 into master Dec 4, 2024
7 checks passed
@gpeal gpeal deleted the gpeal/keyframe-progress-span branch December 4, 2024 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant