Skip to content

Fix change frame rate/speed corrupting selected line duration (#11650)#11653

Merged
niksedk merged 1 commit into
mainfrom
fix/change-framerate-selected-line-duration
Jun 16, 2026
Merged

Fix change frame rate/speed corrupting selected line duration (#11650)#11653
niksedk merged 1 commit into
mainfrom
fix/change-framerate-selected-line-duration

Conversation

@niksedk

@niksedk niksedk commented Jun 16, 2026

Copy link
Copy Markdown
Member

Fixes #11650.

Problem

When changing frame rate (e.g. 25 → 23.976), the currently selected line gets a corrupted end time / duration — sometimes by a few seconds, sometimes by minutes/hours. Every other line scales correctly.

In the reporter's screenshots, line 9 (selected) scales its start correctly (01:05:48,32001:08:36,950) but its end jumps to 01:11:32,782, giving a ~2m55s duration instead of ~1.9s.

Root cause

ChangeFrameRate (and the identical ChangeSpeed) updated each line's times in two separate steps — start first, then end:

line.SetStartTimeOnly(line.StartTime.TotalMilliseconds * ratio);
line.EndTime = line.EndTime.TotalMilliseconds * ratio;

When times grow (ratio > 1), step 1 moves the start past the still-unscaled end, momentarily producing start > end → a negative duration, which is published via change notification.

That transient is harmless for ordinary rows, but the selected row is live two-way-bound to the editor's time/duration up/down controls. The duration control (SecondsUpDown) coerces the negative value to zero and writes it back into the model, which fires OnDurationChanged and moves the end time. Interleaved with step 2, the selected line's end ends up scaled roughly twice (4292.78 ≈ 3950.2 × ratio²). Non-selected rows have no bound controls, so they are unaffected.

Fix

Add SubtitleLineViewModel.SetTimes(start, end) which assigns both times with change notifications suppressed (the same idiom already used by the constructor and UpdateFrom) and recomputes duration once — so no invalid intermediate state is ever exposed to the bound controls. Use it from both ChangeFrameRate and ChangeSpeed (which had the identical latent bug).

Testing

  • dotnet build src/ui/UI.csproj succeeds with 0 warnings / 0 errors.

🤖 Generated with Claude Code

Change frame rate (and change speed) updated each line's start and end
time in two separate steps. When times grow (e.g. 25 -> 23.976), setting
the start first pushes it past the still-unscaled end, briefly producing
start > end / a negative duration that gets published via change
notification.

For the selected line this transient leaks into the editor's two-way
bound time/duration up/down controls: the duration control coerces the
negative value to zero and writes it back into the model, moving the end
time. The result is the selected line's end time scaled roughly twice,
inflating its duration (issue #11650). Non-selected rows have no bound
controls, so they scale correctly.

Add SubtitleLineViewModel.SetTimes(start, end) which assigns both times
with notifications suppressed (the idiom already used by the constructor
and UpdateFrom) and recomputes duration once, so no invalid intermediate
state is ever exposed. Use it from ChangeFrameRate and ChangeSpeed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@niksedk niksedk merged commit 8262e60 into main Jun 16, 2026
1 of 3 checks passed
@niksedk niksedk deleted the fix/change-framerate-selected-line-duration branch June 16, 2026 07:05
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.

RC4 Changing framerate increases text duration randomly

1 participant