ManimCommunity / ManimCommunity/manim

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

Open
#3,040 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue:bug
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior
After each call to Scene's pause() method, I notice a mobject being added to the scene.

```py
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Scene.wait and Scene.pause through the scene and animation handling code to find where the empty Mobject enters self.mobjects. Use the reproduction in the issue to confirm that repeated pauses leave the scene's mobjects unchanged, then run the relevant existing test suite or add coverage for the reported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.