Hashing stability for transient objects in manim 0.20.1 - #4896
Open
pjfo wants to merge 3 commits into
Open
Conversation
…reccyling causing unnecessary partial renders, and added two new tests to the test_hashing test to validate the fix (these tests fail on the current main branch, but pass under this commit)
…reccyling causing unnecessary partial renders, and added two new tests to the test_hashing test to validate the fix (these tests fail on the current main branch, but pass under this commit) -- updated comment in file
This was referenced Jul 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview: What does this pull request change?
It adds a new class variable to the Memoizer class to enable the class to keep objects alive during the serialisation process for calculating hashes, and thus ensures that certain transient objects don't expire mid serialisation and result in unnecessary re-renders of parts of scenes that have not changed.
It also adds two tests both of which assert the fixed behaviour:
Motivation and Explanation: Why and how do your changes improve the library?
In the Memoizer class, there is a bug relating to the caching. In particular transient objects created during serialisation (eg the closure variable dict built for every updater or rate function) are freed mid-pass, and when a later allocation reuses one of those addresses the fresh object is incorrectly collapsed to the "already processed" placeholder. This results in the play hash depending on a race, meaning an identical scene can produce different partial-movie-file hashes from run to run, resulting in unnecessary re-renders of already cached partials.
In some of my scenes I was seeing 42/49 partial's being rerendered even though that scene did not change (it was being included in the render pass because I'm compiling a video and my render script attempts to rerender every scene, as it is not aware of which scene I have changed when it is called). After fixing this in my local copy with a patch file, I got no erroneous re-renders of the partials in this scene.
Links to added or changed documentation pages
This is expected:
manim.utils.hashing source
Unexpected (likely due to commits to main after 0.20.1):
These two I'm surprised by given I didn't change anything that would touch these:
Camera
invert_image
Further Information and Comments
Reviewer Checklist