# Bug report — IK constraint solves differently in editor vs. export/runtime

**File:** success-banner-bug.rev
**Artboard:** `banner` (660×390)
**Animation:** `fall_down` (60 fps, 200 frames, one-shot, no work area)
**Editor:** Rive web editor, macOS 15 (Darwin 25.5), Chrome
**Runtime tested:** rive-flutter (latest) and Rive's own render queue (mp4)

## Summary

An animation that plays back correctly in the editor snaps to a visibly wrong pose in a single frame — between frame 59 and 60 — in **every export**. mp4 renders from the render queue and the exported `.riv` in the Flutter runtime both show the identical snap, and the wrong pose persists to the end of the animation. Scrubbing or playing the same frames in the editor shows no jump at all.

We instrumented the file with a Luau script that drives the animation through the runtime solver and dumps world transforms per frame. It reproduces the snap numerically, and shows that **the inputs to the IK solve are continuous across the boundary while its output is not**.

(Filed separately: while investigating this we found unrelated audio content in one of our renders. That report is not connected to the issue below.)

## Rig

- A rope (9-vertex `PointsPath` with a stroke) skinned to an 8-bone chain: `Root Bone` → `Bone 1` → … → `Bone 7`.
- Six single-bone IK constraints, on `Bone 2`–`Bone 7`, all with `parentBoneCount = 0`, all targeting the same empty group node. Strengths 50 / 60 / 70 / 70 / 80 / 100 %.
- `Root Bone` has a world-space transform constraint (100 %) to a second empty group.
- `Bone 1` carries no IK constraint. Bones 2–7 each carry a flag shape; five of those copy rotation from the flag on `Bone 1`.
- Keyframes exist only on the two empty groups and on the master flag's rotation. No bone is keyframed directly — all bone motion comes from constraints.

## 1. Visual evidence

Decoding the rendered mp4 and computing mean absolute pixel difference between consecutive frames:

```
frame 56  3.5152      frame 60  23.1656   <-- the snap
frame 57  3.2968      frame 61   7.3250
frame 58  3.0239      frame 62   2.5794
frame 59  2.7239      frame 63   1.2889
```

Motion is decaying smoothly (3.5 → 3.3 → 3.0 → 2.7) and then spikes to 23.2 in one frame — a larger single-frame change than anything in the intended animation, whose opening fall peaks at 18.7. The rope goes from a deep smooth curve to nearly straight with a sharp kink at `Bone 2`, the bone nearest the root.

An editor screenshot with the playhead parked on frame 60 shows the correct deep curve. Same file, same frame, different result.

## 2. Numeric evidence (the core of this report)

A Luau utility script instantiates the artboard, steps `fall_down` with `setTimeFrames(f)` + `advance(0)` for f = 0…200, and prints world transforms. Local bone rotations in degrees, relative to parent:

| Frame | Root | Bone 1 | Bone 2 | Bone 3 | Bone 4 | Bone 5 | Bone 6 | Bone 7 |
|---|---|---|---|---|---|---|---|---|
| 58 | 0.579 | −6.343 | −13.123 | −7.343 | −9.789 | −4.024 | −0.804 | −7.293 |
| 59 | 1.153 | −6.343 | −13.451 | −7.560 | −9.902 | −4.061 | −0.818 | −7.294 |
| **60** | 1.653 | −6.343 | **−24.299** | **−10.308** | **−4.449** | **+0.684** | **+1.810** | **+0.778** |
| 61 | 2.074 | −6.343 | −29.966 | −7.930 | −0.055 | +1.738 | +0.801 | −0.299 |

`Bone 7`'s per-frame step goes from 0.0006° to 8.07°. `Bone 1`, the only bone without an IK constraint, never moves — which isolates the IK constraints as the source.

### The inputs are continuous

| Frame | IK target world position | Bone 2 world position | Bone 2 world rotation |
|---|---|---|---|
| 57 | −371.9814, 349.5749 | 493.7676, 99.5226 | 143.459° |
| 58 | −371.6040, 349.7632 | 495.2980, 100.7103 | 143.178° |
| 59 | −371.4801, 349.8250 | 496.6781, 101.7581 | 142.932° |
| **60** | **−371.4801, 349.8250** | 497.8871, 102.6583 | **153.281°** |
| 61 | −371.4801, 349.8250 | 498.9116, 103.4084 | 158.526° |

The target's world position is **bit-identical** across the 59 → 60 boundary. `Bone 2`'s own world position moves smoothly. Both inputs to the aim calculation are continuous, yet the solved rotation steps 10.35° in one frame.

### The constraint is stateful, and it switches fixed point

After the snap, `Bone 2`'s world rotation converges: steps of 5.25, 2.69, 1.40, 0.75, 0.43, 0.25, 0.14 — each roughly half the previous. That ratio of ~0.5 equals `Bone 2`'s IK strength of 50 %, so the constraint appears to filter toward its target angle using strength as the coefficient, carrying state between frames.

It converges to **164.34°**, which is the geometric aim-at-target angle from `Bone 2`'s origin. Before frame 60 it was sitting at ~143° — about 21° off that angle — and was *not* converging toward it. So the solver's target angle changes discontinuously by ~21° while its geometric inputs stay continuous. The editor evidently keeps the ~143° branch for the whole animation.

## 3. Things we ruled out

- **Stale render revision.** We recolored a flag and re-rendered; the color change appeared immediately and the snap was unchanged. Renders do pick up the latest edits.
- **The IK target's last keyframe.** Its x/y keys originally ended at frame 59. We added explicit hold keyframes at frame 200 with identical values, so the animation now interpolates actively across the boundary. The target's world position is identical either way and the snap is unaffected. (These hold keys are still in the file.)
- **`invertDirection`.** Flipping it on all six constraints produced **bit-identical output** across all 200 frames, while a control test (setting all strengths to 0, which correctly pinned every bone to its setup rotation) confirmed property changes do reach the instance. `invertDirection` appears to be a no-op at `parentBoneCount = 0` — possibly a separate bug, or at least a control that should be disabled in the UI in that configuration.

## Attachments

- `success-banner-bug.rev` — the file, reproducing the snap
- `fall_down.mp4` — render showing the snap at frame 60
- Frame stills 58–61 from that render
- Editor screenshot with playhead on frame 60, showing the correct pose
- Photo of the same wrong end-state in the Flutter app on device

The tables above were produced with a short Luau utility script that instantiates the artboard and steps the animation frame by frame. It is not included in the attached file, but is trivial to reproduce — happy to send it if useful.

## Note on the attached file

Two things in it are debugging changes made while investigating, not causes:

- A transform constraint with no target was deleted from `Flags › Root Bone › Bone 1 › Triangle`.
- Hold keyframes were added at frame 200 on the IK target group's x and y.

The snap predates both and is unaffected by them.

## Questions

1. Why does the runtime IK solver pick a different target angle from frame 60 onward when its geometric inputs are continuous, and why does the editor not do the same?
2. Is the IK constraint intended to be stateful across frames, filtering by strength? If so, how is that state expected to stay consistent between editor playback and a cold per-frame runtime solve?
3. Should `invertDirection` have any effect when `parentBoneCount = 0`?
