Skip to content

First motion after MotionDispatcher.Clear() completes in one frame #286

Description

@NeonHazeGameStudio

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

  1. Run a normal 2-second motion and confirm it takes approximately 2 seconds.
  2. Call MotionDispatcher.Clear().
  3. Immediately schedule another 2-second motion.
  4. Measure elapsed realtime and frame count until the motion completes.
  5. Repeat with these schedulers:
    • MotionScheduler.UpdateIgnoreTimeScale
    • MotionScheduler.Update
    • MotionScheduler.UpdateRealtime
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions