Skip to content

Fix floating point errors calculating keyframe end progress#2588

Merged
gpeal merged 5 commits intomasterfrom
gpeal/keyframe-progress-span
Dec 4, 2024
Merged

Fix floating point errors calculating keyframe end progress#2588
gpeal merged 5 commits intomasterfrom
gpeal/keyframe-progress-span

Conversation

@gpeal
Copy link
Copy Markdown
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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 4, 2024

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 4, 2024

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 4, 2024

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

@github-actions
Copy link
Copy Markdown

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
@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