Skip to content

fix(runtime): guard dotlottie v1 seek against zero duration - #1577

Closed
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:fix/dotlottie-seek-zero-duration
Closed

fix(runtime): guard dotlottie v1 seek against zero duration#1577
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:fix/dotlottie-seek-zero-duration

Conversation

@calcarazgre646

Copy link
Copy Markdown
Contributor

Problem

The dotlottie-web v1 seek branch (lottie.ts) computed (time / duration) * 100 with duration = anim.duration ?? 1. Nullish coalescing does not replace 0, so a player reporting duration: 0 (not yet loaded, which is exactly the bootstrap-time discover to seek window) produced (time / 0) * 100 = NaN, and seek(NaN) blanked the first frame at composition time 0. The v2 branch directly above already guards with if (totalFrames > 0); the v1 sibling did not.

Change

Mirror the v2 guard: default duration to 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 (no seek(NaN)). Verified load-bearing (reverting the fix makes the zero-duration case call seek(NaN)). Full core suite green.

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].
@jrusso1020

Copy link
Copy Markdown
Collaborator

Continuing this contribution in #3651, rebuilt on current main with regression coverage and attribution to this PR. Keeping this PR open until the successor lands. Thanks for the original fix.

@jrusso1020

Copy link
Copy Markdown
Collaborator

Closing as implemented in #3651, now merged. The successor preserves this contribution while updating it for current main and adding regression coverage. Thanks for the original fix.

@jrusso1020 jrusso1020 closed this Sep 4, 2026
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.

2 participants