ManimCommunity / ManimCommunity/manim

Changing VGroup contents during animation displays a copy of the original state during animation

Open
#2,309 1 comment 1 reaction 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
I'm trying to create a custom group of objects that changes contents depending on some value. So i've extended from VGroup and have a method that sets it up. This works quite well, however, if you change the value with an animation (e.g., via a tracker+updater), a copy of the original state of the object can be seen during the animation. The copy vanishes right afterwards.

## Expected behavior
The opengl renderer actually exhibits the expected behaviour, i.e., the original state it not seen during animation. This only affects the cairo renderer.

## How to reproduce the issue
I've stripped my problem down to a minimal example. I know this example could be solved much easier by moving the `Dot` itself, the larger thing I'm working on just has a lot more objects that have to be created/removed depending on the value.

Code for reproducing the problem

```py
import manim as mn
class TestGroup(mn.VGroup):
def __init__(self, something, **kwargs):
super().__init__(**kwargs)
self.dot = None
self.set_something(something)
def set_something(self, something):
self.remove(self.dot)
self.dot = mn.Dot(mn.RIGHT * something)
self.add(self.dot)

class TestScene(mn.Scene):
def construct(self):
tracker = mn.ValueTracker(0)
test = TestGroup(tracker.get_value())
test.add_updater(lambda x: x.set_something(tracker.get_value()))
self.add(test)
self.wait(0.5)
self.play(tracker.animate.set_value(5))
self.wait(0.5)
```

## Additional media files

Images/GIFs
![TestScene_ManimCE_v0 12 0](https://user-images.githubusercontent.com/751884/142602836-44376b71-18bb-4b93-bdde-1215888270c7.gif)

## Logs
Terminal output

```
Manim Community v0.12.0

[11/19/21 10:53:48] DEBUG Animation with empty mobject animation.py:165
INFO Caching disabled. cairo_renderer.py:64
DEBUG List of the first few animation hashes of the scene: ['uncached_00000'] cairo_renderer.py:83
INFO Animation 0 : Partial movie file written in scene_file_writer.py:510
'/Volumes/projects/latticeanim/media/videos/test/480p15/partial_movie_files/TestScene/uncached_00000.mp4'
INFO Caching disabled. cairo_renderer.py:64
DEBUG List of the first few animation hashes of the scene: ['uncached_00000', 'uncached_00001'] cairo_renderer.py:83
INFO Animation 1 : Partial movie file written in scene_file_writer.py:510
'/Volumes/projects/latticeanim/media/videos/test/480p15/partial_movie_files/TestScene/uncached_00001.mp4'
DEBUG Animation with empty mobject animation.py:165
INFO Caching disabled. cairo_renderer.py:64
DEBUG List of the first few animation hashes of the scene: ['uncached_00000', 'uncached_00001', 'uncached_00002'] cairo_renderer.py:83
INFO Animation 2 : Partial movie file written in scene_file_writer.py:510
'/Volumes/projects/latticeanim/media/videos/test/480p15/partial_movie_files/TestScene/uncached_00002.mp4'
INFO Combining to Movie file. scene_file_writer.py:604
DEBUG Partial movie files to combine (3 files): scene_file_writer.py:547
['/Volumes/projects/latticeanim/media/videos/test/480p15/partial_movie_files/TestScene/uncached_00000.mp4',
'/Volumes/projects/latticeanim/media/videos/test/480p15/partial_movie_files/TestScene/uncached_00001.mp4',
'/Volumes/projects/latticeanim/media/videos/test/480p15/partial_movie_files/TestScene/uncached_00002.mp4']
INFO scene_file_writer.py:718
File ready at '/Volumes/projects/latticeanim/media/videos/test/480p15/TestScene_ManimCE_v0.12.0.gif'

INFO Rendered TestScene scene.py:234
Played 3 animations
INFO Previewed File at: '/Volumes/projects/latticeanim/media/videos/test/480p15/TestScene.gif' file_ops.py:202

```

## System specifications

System Details

- OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)): macOS 12 (also reproduced on ArchLinux)
- RAM: 16GB
- Python version (`python/py/python3 --version`): Python 3.9.8
- Installed modules (provide output from `pip list`):

```
Package Version
---------------------- ---------
appnope 0.1.2
astroid 2.6.6
autopep8 1.5.7
backcall 0.2.0
beniget 0.4.1
black 21.10b0
certifi 2021.10.8
charset-normalizer 2.0.7
click 8.0.3
click-default-group 1.2.2
cloup 0.7.1
colorama 0.4.4
colour 0.1.5
commonmark 0.9.1
Cython 0.29.24
decorator 5.1.0
flake8 3.9.2
gast 0.5.2
glcontext 2.3.4
grpcio 1.42.0
idna 3.3
ipython 7.29.0
isort 5.10.1
isosurfaces 0.1.0
jedi 0.18.0
lazy-object-proxy 1.6.0
manim 0.12.0
ManimPango 0.3.1
mapbox-earcut 0.12.10
matplotlib-inline 0.1.3
mccabe 0.6.1
moderngl 5.6.4
moderngl-window 2.4.0
multipledispatch 0.6.0
mypy-extensions 0.4.3
networkx 2.6.3
numpy 1.21.3
parso 0.8.2
pathspec 0.9.0
pexpect 4.8.0
pickleshare 0.7.5
Pillow 8.4.0
pip 21.2.4
platformdirs 2.4.0
pluggy 1.0.0
ply 3.11
prompt-toolkit 3.0.22
ptyprocess 0.7.0
pybind11 2.8.1
pycairo 1.20.1
pycodestyle 2.7.0
pydocstyle 6.1.1
pydub 0.25.1
pyflakes 2.3.1
pyglet 1.5.21
Pygments 2.10.0
pylint 2.9.6
pyobjc-core 7.3
pyobjc-framework-Cocoa 7.3
pyrr 0.10.3
python-lsp-jsonrpc 1.0.0
python-lsp-server 1.2.4
pythran 0.10.0
regex 2021.11.2
requests 2.26.0
rich 10.12.0
rope 0.21.1
scipy 1.7.1
screeninfo 0.6.7
setuptools 59.0.1
six 1.16.0
skia-pathops 0.7.1
snowballstemmer 2.1.0
toml 0.10.2
tomli 1.2.2
tqdm 4.62.3
traitlets 5.1.1
typing-extensions 3.10.0.2
ujson 4.2.0
urllib3 1.26.7
watchdog 2.1.6
wcwidth 0.2.5
wrapt 1.12.1
yapf 0.31.0
```

LaTeX details

+ LaTeX distribution (e.g. TeX Live 2020): mactex 2021
+ Installed LaTeX packages: full installation

FFMPEG

Output of `ffmpeg -version`:

```
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 13.0.0 (clang-1300.0.29.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/4.4.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
```

## Additional comments
None

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 reproducing the minimal TestScene with the Cairo renderer, then inspect the animation.py and cairo_renderer.py paths involved in updater-driven rendering; the logs also identify scene.py as an entry point. Done means the original VGroup state is not displayed during the animation under Cairo, while the existing OpenGL behavior remains correct.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.