Kinematica: Inconsistent delta time reported when rewinding in snapshot debugger

When rewinding with the snapshot debugger, Debugger.instance.deltaTime will have an inaccurate value on the first frame after scrubbing the debugger to a new recorded frame. This results in a noticeable jitter when scrubbing the debugger between frames with a large difference in delta times:

7068598--840073--snapshot-debugger-jitter.gif

This can be reproduced consistently with the following steps:

  • Enter play mode.
  • In the snapshot debugger window, begin recording.
  • Record at least a few seconds of animation data (i.e. where at least one character is animating through Kinematica).
  • Pause the snapshot debugger (either by pressing “pause recording” or by clicking on the snapshot debugger timeline).
  • Slowly scrub through the snapshot debugger until you notice a frame that jitters visibly when you scrub to it.
  • Set the debug timeline to just before the frame that has the jitter.
  • Pause the editor.
  • Set the debug timeline to the frame that has the jitter.
  • Hit the next frame button (i.e. the one to the right of the pause button).
  • Hit the next frame button again.

Here you’ll see that the first execution of the recorded frame produces slightly different results than all subsequent frames.

In debugging this issue, it looks like the problem is that Debugger.instance.deltaTime will still have the value from the last-simulated frame when OnEarlyUpdate(), which is the point at which the Kinematica component stores the delta time for use by the synthesizer. Internally, Debugger restores the recorded snapshot in OnPreUpdate(), which is called after OnEarlyUpdate(), which means that Kinematica (and consequently the synthesizer) doesn’t have the correct delta time until the second time a recorded frame is run.

It’s unclear to me what the correct fix here is. It’s possible that Debugger needs to be updated to restore the snapshot in OnEarlyUpdate(), that way all code for the simulated frame is correctly synced. If I can, I’d like to find a workaround for this that doesn’t involve modifying the Kinematica source code, that way anybody else working with Kinematica 0.8 during the hiatus can also make use of it. Will update if I figure anything out.

cc @Tautvydas-Zilys

Does this look like something your wisdom and insights can provide wisdom and insight about?

Oh, for anyone looking at this now, I have a forked version of Kinematica up on GitHub where I was working on a fix for this issue (among others). Here’s the fix that I initially came up with. It seems to address the jitter issue, but I suspect that fix also makes some unwanted changes, and have written up some additional thoughts on that.