Skip to content

[Timeline] Fix #205 keyframe move crash - #211

Merged
ManlyMarco merged 2 commits into
IllusionMods:mainfrom
Lusiocc:fix/issue-205-keyframe-crash
Jul 26, 2026
Merged

[Timeline] Fix #205 keyframe move crash#211
ManlyMarco merged 2 commits into
IllusionMods:mainfrom
Lusiocc:fix/issue-205-keyframe-crash

Conversation

@Lusiocc

@Lusiocc Lusiocc commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Description

Dropping a keyframe on a time that was already taken lost it. It got pulled out of the track before anything checked the new spot was free, and then putting it back failed. The keyframe still showed on screen but was gone from the track, and Timeline stopped responding until Studio was restarted.

Now the spot is checked before anything moves. If it's taken, nothing moves and a message says why. Keyframes moving together are moved in an order that lets them pass through each other's old positions.

Also fixed: adding a keyframe on top of another dumped an exception in the log, gap closing could try to move keyframes before the start of the timeline, and Alt paste stayed quiet when it couldn't make room.

Motivation and Context

Issue #205

How Has This Been Tested?

In Studio on HS2 and KK

  • The repro from the issue: two keyframes selected, Alt+drag forward with Shift so the left one lands on the right one's old spot
  • Same drag backwards
  • Dragging onto a keyframe that isn't selected, which should move nothing at all
  • Dropping a keyframe back where it started
  • Dragging a selection spanning two tracks
  • Scaling a selection spanning two tracks, including tracks with keyframes at the same time
  • Cut and paste with Alt
  • Gap closing on one track
  • Gap closing on two tracks with different sized gaps
  • Gap closing with a keyframe left in between, which correctly refuses to move it before the start of the timeline

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Dropping a keyframe on a time that was already taken lost it. It got pulled out of the track before we knew the new spot was free, and then putting it back failed. Check first, and allow for the tiny rounding that comes from working the time out from pixels.

AddKeyframe never checked either. Also don't shift keyframes to a negative time when closing a gap.

Signed-off-by: Lusiocc <252649741+Lusiocc@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Timeline keyframe move edge cases that could orphan keyframes and leave the Timeline UI unresponsive, by pre-checking destination occupancy and introducing safer “try move” semantics for move/scale/paste/gap-close flows.

Changes:

  • Pre-check keyframe drag-move destinations for collisions and apply ordered moves to allow selected keyframes to “pass through” prior positions.
  • Add FindOccupant (approximate-time collision detection) and TryMoveKeyframe to avoid orphaning keyframes / throwing on overlaps.
  • Harden paste-with-Alt and gap-closing behaviors with user-facing log messages and additional safety checks.
Comments suppressed due to low confidence (1)

Timeline.Core/Timeline.cs:2827

  • ScaleKeyframeSelection ignores the TryMoveKeyframe() return value. If a move fails (e.g., keyframe not found in its parent list), scaling would silently apply a partial transformation and then refresh the UI, leaving selection/state out of sync.
            for (int i = 0; i < _selectedKeyframes.Count; i++)
            {
                KeyValuePair<float, Keyframe> pair = _selectedKeyframes[i];
                float newTime = (float)(((pair.Key - min) * newSize) / currentSize + min);
                TryMoveKeyframe(pair.Value, newTime);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Timeline.Core/Timeline.cs Outdated
Comment thread Timeline.Core/Timeline.cs
Signed-off-by: Lusiocc <252649741+Lusiocc@users.noreply.github.com>
@ManlyMarco
ManlyMarco merged commit 0b3f9b7 into IllusionMods:main Jul 26, 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.

[KK/KKS][Timeline] Plugin crashes when Alt+click moving keyframes (under specific condition)

3 participants