Description
Description of bug / unexpected behavior
I found that certain operations on ImageMobject
s do not invalidate the animation cache, that is, they don't change the mobject's hash value.
In consequence, in a typical workflow of repeated renders, Manim sometimes generates videos that do not match the code they were generated with.
This is because the pixel_array
is explicitly filtered out of the hashing operation:
Lines 21 to 26 in b26137e
Expected behavior
All (visible) modifications to an ImageMobject
should result in its hash being different.
How to reproduce the issue
Code for reproducing the problem
- Run the provided code (
manim filename.py
without amanim.cfg
) - Change the alpha value
- Run it again
- Manim inappropriately re-uses the cached animation.
from manim import *
class TestImageCaching(Scene):
def construct(self):
im = ImageMobject('example.png')
# change here ↓↓↓
im.set_color(RED, alpha=0.2)
self.add(im)
self.wait()
Additional comments
The most obvious “fix” would be to remove "pixel_array"
from the exclude list – which, considering that #2923 works, doesn't break Manim – but I assume it's there for a reason.
Edit: As you can see in the code snipped below, #2923 “works”, because a repr
of the (truncated) array is hashed, not all of its values. In other words, this only works if you're lucky.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status