Skip to content

Extra frame of animation with dt-updater #4611

@wildmathing

Description

@wildmathing

Description of bug / unexpected behavior

Playing animations with the dt-updater added results in duplicate frames. This issue is especially noticeable at low FPS or when using TracedPath.

Code for reproducing the problem
config.frame_rate = 5
class DtUpdaterBug(Scene):
    def construct(self):
        circle = Circle().set_fill(RED, 1).to_edge(LEFT)

        def upd_circle(mob, dt):
            mob.shift(2 * dt * RIGHT)

        def upd_cnt(cnt, dt):
            cnt.increment_value(dt * config.frame_rate)

        counter = Integer().shift(UP * 2).add_updater(upd_cnt)
        circle.add_updater(upd_circle)
        self.add(counter, circle)
        self.wait(2)
        error = Text("Error: extra frame for every animation")
        self.add(error.to_edge(UP).scale(0.6))
        for _ in range(5):
            self.play(Animation(VMobject()), run_time=1 / 5)
            self.wait(3 / 5)
        self.remove(error)
        self.wait(2)

Additional comments

https://discord.com/channels/1453870851807117363/1463725322313666655

DtUpdaterBug.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions