ManimCommunity / ManimCommunity/manim

0 `dt` value passed into updater between animations/waits

Open
#3,005 2 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
If an updater uses the `dt` parameter, then `dt` will be 0 for one frame between animations/waits. This causes choppy movement, which is especially noticeable with low quality renders.

## Expected behavior

The `dt` parameter in an updater should correctly reflect the difference in time between frames, including the time between the last frame of one animation and the first frame of the next.

## How to reproduce the issue

Code for reproducing the problem

This code should rotate the line 180 degrees every second, so it should be horizontal after each second. However, the line visibly pauses between each of the ten 1-second waits, and by the end it has deviated pretty far from its horizontal orientation.

```py
class Choppy(Scene):
def construct(self):
line = Line()
self.add(line)

def updater(line: Line, dt):
line.rotate(PI * dt)

line.add_updater(updater)

self.wait()
self.wait()
self.wait()
self.wait()
self.wait()
self.wait()
self.wait()
self.wait()
self.wait()
self.wait()
```

This alternative version with just one 10-second wait behaves more or less as expected however.

```
class Smooth(Scene):
def construct(self):
line = Line()
self.add(line)

def updater(line: Line, dt):
line.rotate(PI * dt)

line.add_updater(updater)

self.wait(10)
```

## Additional media files

Images/GIFs

Choppy - current behavior with ten 1-second waits:
https://user-images.githubusercontent.com/22244974/198778137-f218f1b5-22f7-48db-8a0a-95b5a93c52b9.mp4

Smooth - correct-looking behavior with one 10-second wait:
https://user-images.githubusercontent.com/22244974/198778579-e5b99950-003e-4b17-ac5e-916725febe1e.mp4

## Logs
Terminal output

```
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
```

## System specifications

System Details

- OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Windows 10 Home 21H1
- RAM: 16 gB
- Python version (`python/py/python3 --version`): 3.10.5
- Installed modules (provide output from `pip list`):
```
Package Version
------------------- ------------
certifi 2022.6.15
charset-normalizer 2.0.12
click 8.1.3
click-default-group 1.2.2
cloup 0.13.1
colorama 0.4.5
colour 0.1.5
commonmark 0.9.1
decorator 5.1.1
glcontext 2.3.6
idna 3.3
isosurfaces 0.1.0
manim 0.16.0.post0
ManimPango 0.4.1
mapbox-earcut 0.12.11
moderngl 5.6.4
moderngl-window 2.4.1
multipledispatch 0.6.0
networkx 2.8.4
numpy 1.22.4
Pillow 9.1.1
pip 22.2.2
pycairo 1.21.0
pydub 0.25.1
pyglet 1.5.26
Pygments 2.12.0
pyrr 0.10.3
requests 2.28.0
rich 12.4.4
scipy 1.8.1
screeninfo 0.8
setuptools 58.1.0
six 1.16.0
skia-pathops 0.7.2
srt 3.5.2
tqdm 4.64.0
urllib3 1.26.9
watchdog 2.1.9
wheel 0.37.1
```

LaTeX details

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:

FFMPEG

Output of `ffmpeg -version`:

```
ffmpeg version 5.0.1-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
```

## Additional comments

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 running the reported Choppy and Smooth examples with the updater and repeated versus single wait calls, then trace how Scene, Line, updater, and wait interact across frames. Done means the updater receives the correct elapsed time between animations or waits and the repeated-wait example no longer pauses or drifts.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.