Skip to content

Rollup animation fix and test - #298

Merged
palemieux merged 2 commits into
sandflow:mainfrom
dheitmueller:rollup-animation-test
Nov 9, 2026
Merged

palemieux merged 2 commits into
sandflow:mainfrom
dheitmueller:rollup-animation-test

Conversation

@dheitmueller

@dheitmueller dheitmueller commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

This patch series addresses a rendering bug when using the rollup mode that resulted in overlapping rows. Also included it a test for this issue.

Closes #299

@palemieux

Copy link
Copy Markdown
Contributor

I do not see an overlap with the test file at src/test/js/RollUpTest.js. Which browser/OS are you using? Can you attach a video?

@dheitmueller

Copy link
Copy Markdown
Contributor Author

I didn't accurately describe the behavior (it's a momentary shift, not an overlap), and it's pretty subtle. I'm attaching an annotated video which shows the behavior (captured with Chrome on MacOS).

rollup-before-after.mp4

@dheitmueller

Copy link
Copy Markdown
Contributor Author

I would encourage you to download the video and step through it frame-by-frame as opposed to trying to watch it in realtime in Github's video player.

@palemieux

Copy link
Copy Markdown
Contributor

@dheitmueller Great catch! I would however:

  • use const h = rb.plist[rb.plist.length - 1].after - rb.plist[rb.plist.length - 2].after; since we are offsetting the height of the last line
  • vary the line heights in the unit test to emphasize the issue

@dheitmueller

Copy link
Copy Markdown
Contributor Author

@palemieux Thanks for the feedback. I'll implement your two suggested changes and re-push the patch series.

@dheitmueller
dheitmueller force-pushed the rollup-animation-test branch from 1b3edcb to 8ff13ef Compare November 9, 2026 18:33
Comment thread src/test/js/RollUpTest.js Resolved
renderHTML() animates a region that is aligned after when enableRollUp
is set and the last line of the previous ISD is the second to last line
of the current one, but nothing tests it: the reference files test
renders each ISD on its own.

Render a roll-up caption ISD by ISD in the browser, as a player does,
passing the state that renderHTML() returns to the next call, and check
that:

* the lines start the animation from where they were: the offset of the
  animation is the distance that the lines of the previous ISD moved up
  to get to their place in the current one, with lines of the same size
  and with lines of different sizes, with the line height of the font
  and with a smaller one;
* they do not roll up if enableRollUp is not set, if the lines of the
  previous ISD are not the first lines of the current one, and in the
  first ISD.

The tests with a line height smaller than the font fail until the
distance of the animation is the one between the lines instead of the
height of the box of the last line.
When renderHTML() is called with enableRollUp, the region is moved up
by one line and slides back into place. The distance was the height of
the box of the last line, which is the distance that the lines have to
move only if the line height is the natural one of the font ("normal").

With a smaller line height, such as the one row that CEA-608
conversions set with tts:lineHeight so that rows stay on a cell grid,
the box of a line (the ascent and the descent of the font) is taller
than the distance between two lines: with a monospace font of 1c on a
1280x720 picture with 19 rows the box is 47 px and the distance 38 px.
The lines then start 9 px lower than where the previous lines were,
which shows as a small jump before they slide.

Use the distance between the after edges of the last two lines, which
is the height that the last line adds to the region, and so how far
the previous lines have to move. There are at least two lines in the
region at this point. The final position of the lines is not changed,
nor is the condition for the animation.
@dheitmueller
dheitmueller force-pushed the rollup-animation-test branch from 8ff13ef to 7b86fc5 Compare November 9, 2026 19:18
@palemieux
palemieux merged commit d842e6c into sandflow:main Nov 9, 2026
1 check passed
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.

Roll-up animation does not use the full height of the trailing line, resulting in a subtle jump

2 participants