Skip to content

Scene.wait (and .pause) calls add an empty Mobject to self.mobjects #3040

Open
@kjlubick

Description

@kjlubick

Description of bug / unexpected behavior

After each call to Scene's pause() method, I notice a mobject being added to the scene.

class PauseMobjects(Scene):
    def construct(self):
        print(self.mobjects)
        yellow = Square()

        self.play(FadeIn(yellow))
        print(self.mobjects)

        for i in range(0, 5):
            self.pause()
            print(self.mobjects)

Console while running above:

[]
[Square]
[Square, Mobject]
[Square, Mobject, Mobject]
[Square, Mobject, Mobject, Mobject]
[Square, Mobject, Mobject, Mobject, Mobject]
[Square, Mobject, Mobject, Mobject, Mobject, Mobject]
[Square, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject]
[Square, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject]
[Square, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject]
[Square, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject]
[Square, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject, Mobject]

Nothing is rendered here, but I worry that these excess mobjects could be reducing performance, especially because hasing the scene is O(n) where n is the number of mobjects in the scene (e.g. #2710 )

Expected behavior

I would not expect pausing or otherwise waiting to change the mobjects in the scene. From what I've poked around, it's not apparent to me that adding a Mobject is important for waits, so hopefully this can be removed.

Discussion

I am working on a fix, trying to figure out where this mobject is added and prevent that, or at least make sure the mobject is cleaned up after the animation finishes.

This is with v0.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue:bugSomething isn't working... For use in issues

    Type

    No type

    Projects

    Status

    🆕 New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions