First motion after MotionDispatcher.Clear() completes in one frame
Summary
A motion scheduled immediately after MotionDispatcher.Clear() can complete in a single frame, even when its duration is set to 2.0 seconds.
This was reproduced with:
MotionScheduler.UpdateIgnoreTimeScale
MotionScheduler.Update
MotionScheduler.UpdateRealtime
Environment
- Unity:
2021.3.45f2
- Render pipeline: URP
- LitMotion package:
com.annulusgames.lit-motion
- LitMotion version:
2.0.2
Expected behavior
After calling MotionDispatcher.Clear(), a newly scheduled motion with duration 2.0 should animate for approximately 2 seconds.
Actual behavior
The first motion scheduled immediately after MotionDispatcher.Clear() completes in 1 frame.
Observed failing results immediately after MotionDispatcher.Clear():
MotionScheduler.UpdateIgnoreTimeScale
- Result: fail
- Elapsed:
0.015s
- Frames:
1
MotionScheduler.Update
- Result: fail
- Elapsed:
0.003s
- Frames:
1
MotionScheduler.UpdateRealtime
- Result: fail
- Elapsed:
0.004s
- Frames:
1
Observed passing results after waiting two player-loop yields following MotionDispatcher.Clear():
MotionScheduler.UpdateIgnoreTimeScale
- Result: pass
- Elapsed:
2.001s
- Frames:
413
MotionScheduler.Update
- Result: pass
- Elapsed:
2.004s
- Frames:
451
MotionScheduler.UpdateRealtime
- Result: pass
- Elapsed:
2.004s
- Frames:
451
Reproduction outline
- Run a normal 2-second motion and confirm it takes approximately 2 seconds.
- Call
MotionDispatcher.Clear().
- Immediately schedule another 2-second motion.
- Measure elapsed realtime and frame count until the motion completes.
- Repeat with these schedulers:
MotionScheduler.UpdateIgnoreTimeScale
MotionScheduler.Update
MotionScheduler.UpdateRealtime
- Repeat the same test after waiting two player-loop yields after
MotionDispatcher.Clear().
Notes
- This does not appear to be specific to one scheduler, because all tested schedulers failed when used immediately after
MotionDispatcher.Clear().
- Waiting two player-loop yields after
MotionDispatcher.Clear() makes the same schedulers behave correctly.
- I found the closed
UpdateRunner.Reset fix, but this issue still reproduces in LitMotion 2.0.2.
First motion after
MotionDispatcher.Clear()completes in one frameSummary
A motion scheduled immediately after
MotionDispatcher.Clear()can complete in a single frame, even when its duration is set to2.0seconds.This was reproduced with:
MotionScheduler.UpdateIgnoreTimeScaleMotionScheduler.UpdateMotionScheduler.UpdateRealtimeEnvironment
2021.3.45f2com.annulusgames.lit-motion2.0.2Expected behavior
After calling
MotionDispatcher.Clear(), a newly scheduled motion with duration2.0should animate for approximately 2 seconds.Actual behavior
The first motion scheduled immediately after
MotionDispatcher.Clear()completes in 1 frame.Observed failing results immediately after
MotionDispatcher.Clear():MotionScheduler.UpdateIgnoreTimeScale0.015s1MotionScheduler.Update0.003s1MotionScheduler.UpdateRealtime0.004s1Observed passing results after waiting two player-loop yields following
MotionDispatcher.Clear():MotionScheduler.UpdateIgnoreTimeScale2.001s413MotionScheduler.Update2.004s451MotionScheduler.UpdateRealtime2.004s451Reproduction outline
MotionDispatcher.Clear().MotionScheduler.UpdateIgnoreTimeScaleMotionScheduler.UpdateMotionScheduler.UpdateRealtimeMotionDispatcher.Clear().Notes
MotionDispatcher.Clear().MotionDispatcher.Clear()makes the same schedulers behave correctly.UpdateRunner.Resetfix, but this issue still reproduces in LitMotion2.0.2.