fix(runtime): guard dotlottie v1 seek against zero duration#1577
Open
calcarazgre646 wants to merge 1 commit into
Open
fix(runtime): guard dotlottie v1 seek against zero duration#1577calcarazgre646 wants to merge 1 commit into
calcarazgre646 wants to merge 1 commit into
Conversation
The dotlottie-web v1 seek branch computed (time / duration) * 100 with duration = anim.duration ?? 1. Nullish coalescing does not replace 0, so a player reporting duration 0 (not yet loaded, the bootstrap-time discover->seek window) produced (time / 0) * 100 = NaN, and seek(NaN) blanked the first frame at composition time 0. The v2 branch right above already guards with if (totalFrames > 0). Mirror that guard: default duration to 0 and seek only when it is positive, with the percentage clamped to [0, 100].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The dotlottie-web v1 seek branch (
lottie.ts) computed(time / duration) * 100withduration = anim.duration ?? 1. Nullish coalescing does not replace0, so a player reportingduration: 0(not yet loaded, which is exactly the bootstrap-timediscovertoseekwindow) produced(time / 0) * 100 = NaN, andseek(NaN)blanked the first frame at composition time 0. The v2 branch directly above already guards withif (totalFrames > 0); the v1 sibling did not.Change
Mirror the v2 guard: default
durationto 0 and seek only when it is positive, with the percentage clamped to[0, 100]. No change for a loaded player with a known duration.Tests
Two cases in
lottie.test.ts: a v1 player with a known duration still seeks by percentage; a v1 player reporting duration 0 is not seeked (noseek(NaN)). Verified load-bearing (reverting the fix makes the zero-duration case callseek(NaN)). Full core suite green.