Repository navigation
fix(lint): derive the root duration with the parser's timing reader - #8032
Conversation
`deriveDurationFromClips` read `data-start` with a raw `Number()`, so a clip authored at `data-start="-2"` produced an end of `-1`. `resolveCompositionDuration` only counts positive ends, so the clip vanished from the derivation and the composition was reported as having no duration source at all — a hard error that blocks strict renders, even though the parser clamps the same start to zero and renders the clip for its full length. Read the start through `readClipTiming`, the same contract parser the renderer uses, and keep the media-duration default for untimed images.
jrusso1020
left a comment
There was a problem hiding this comment.
Approving. Reading data-start through readClipTiming clamps an absolute start to 0, so a clip with a negative start now counts toward the derived duration instead of being dropped. The runtime (core/src/runtime/init.ts) and the parser clamp the same way, so lint now matches the renderer, including the -0.5 case in #8031.
fails without the fix: root_composition_missing_duration_source > derives from a negative start like the parser does. With main's composition.ts, that test fails (1 failed, 321 passed). At this head the full lint suite passes, 1328/1328, and tsc --noEmit is clean.
The one other behavior change: when data-duration is ≤0 or non-numeric and data-end is valid, the clip is now dropped instead of falling back to end - start. That input is malformed and this matches the parser, so it doesn't block. A test or a line in the PR body would make the change explicit.
Optional nits:
composition.ts:1974-1976repeatsreadTagTiming(rawTag)(L84).readTagTiming(tag.raw)would do the same.- Follow-up, not for this PR:
core/src/compiler/timingCompiler.ts(~L194) still adds start and duration without the clamp when it writesdata-end. A negative start then yieldsdata-end=-1next to a clamped end of 1, which triggersconflicting-end. - #8037 edits a different hunk of the same file. Whichever lands second may need a rebase.
Review by Rames
`deriveDurationFromClips` read `data-start` with a raw `Number()`, so a clip authored at `data-start="-2"` produced a negative end and vanished from the derivation. Read the start through `readClipTiming`, which clamps it to zero, and keep `readAuthoredDurationSeconds` for the authored length so a valid `data-end` still backs an unparseable `data-duration`.
|
Thanks — fixed the
|
jrusso1020
left a comment
There was a problem hiding this comment.
Re-approving at d30df74. The new commit makes two changes:
- The start is read with
readTagTiming(tag.raw), which was my nit. - The authored length now comes from
readAuthoredDurationSeconds(getAttr, start). Whendata-durationisn't numeric, it falls back todata-end - startagain, as it did on main, and the start is now clamped.
That closes the behavior change I noted. The new test checks it: falls back to a valid data-end when data-duration is not numeric. With that line reverted to timing.duration, the test fails (1 failed, 322 passed). At this head, composition.test.ts passes 323/323 and tsc --noEmit in packages/lint is clean.
Review by Rames
What
Derive a composition's root length from its clips through the same timing contract the renderer uses, instead of re-parsing
data-startwith a rawNumber(). A clip authored atdata-start="-2"no longer disappears from the derivation.Why
deriveDurationFromClipsreaddata-startwithNumber(), so-2produced an end of-1.resolveCompositionDurationonly counts positive ends, so the clip vanished and the composition was reported asroot_composition_missing_duration_source— an error that blocks strict renders — even though the parser clamps the same start to zero and renders the clip for its full length.The same mismatch made
data-start="-0.5"report "at least 1.5s" while the renderer runs 2s.Related work
Fixes #8031.
The derivation rule itself came from #4174 ("a composition with no authored length takes it from its clips"); this keeps that feature's behavior for media defaults while aligning the start parsing with
readClipTiming.How
deriveDurationFromClipsnow callsreadClipTimingwith the tag's attribute reader.timing.startis the parser's clamped start (ornullfor a reference start, which stays a runtime-pending clip), andtiming.durationis the authored length, including the legacydata-endpath.Test plan
composition.test.tsnew case:data-start="-2"+data-duration="1"→root_composition_duration_derived"at least 1s"; fails onmainwith the missing-source error.@hyperframes/lint typecheckpasses.comment-ratchetandoxfmt --checkpass on the changed files.Commands run: