Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal shows error after quitting interactive mode #4019

Open
minhvt98 opened this issue Nov 15, 2024 · 1 comment
Open

Terminal shows error after quitting interactive mode #4019

minhvt98 opened this issue Nov 15, 2024 · 1 comment

Comments

@minhvt98
Copy link

minhvt98 commented Nov 15, 2024

Description of bug / unexpected behavior

When I try using Manim's interactive mode in VSC, the animations are shown. However, as soon as I quit the gui (by pressing Q), the terminal shows errors before closing. The error messages are in the form of AttributeError: X has no attribute Y. This behaviour appears whether I debug with VSC or run the file using manim cli. It also appears no matter what animation I'm using.
Here's an example:

[11/15/24 19:21:47] INFO     Rendered TestOpenGL                                                                                      scene.py:247
                             Played 3 animations
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ c:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\cli\render\commands.py:120 in       │
│ render                                                                                           │
│                                                                                                  │
│   117 │   │   │   try:                                                                           │
│   118 │   │   │   │   with tempconfig({}):                                                       │
│   119 │   │   │   │   │   scene = SceneClass()                                                   │
│ ❱ 120 │   │   │   │   │   scene.render()                                                         │
│   121 │   │   │   except Exception:                                                              │
│   122 │   │   │   │   error_console.print_exception()                                            │
│   123 │   │   │   │   sys.exit(1)                                                                │
│                                                                                                  │
│ c:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\scene\scene.py:229 in render        │
│                                                                                                  │
│    226 │   │   """                                                                               │
│    227 │   │   self.setup()                                                                      │
│    228 │   │   try:                                                                              │
│ ❱  229 │   │   │   self.construct()                                                              │
│    230 │   │   except EndSceneEarlyException:                                                    │
│    231 │   │   │   pass                                                                          │
│    232 │   │   except RerunSceneException as e:                                                  │
│                                                                                                  │
│ D:\manimce\testgl.py:20 in construct                                                             │
│                                                                                                  │
│   17 │   │   │   color=PINK                                                                      │
│   18 │   │   )                                                                                   │
│   19 │   │                                                                                       │
│ ❱ 20 │   │   self.camera.set_euler_angles(theta=0*DEGREES,phi=40*DEGREES,gamma=0*DEGREES)        │
│   21 │   │   self.play(Create(surface))                                                          │
│   22 │   │   self.play(Transform(surface,surface_1),run_time=3)                                  │
│   23 │   │   self.play(surface.animate.shift(np.array((0.0, 0.0, -3.0))))                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Camera' object has no attribute 'set_euler_angles'

Expected behavior

It should quit with no error message

How to reproduce the issue

Python code to replicate the shown error
from manim import *
from manim.opengl import *

class TestOpenGL(Scene):
    def construct(self):        
        surface = OpenGLSurface(
            lambda u,v: (u, v, np.sqrt(u**2+v**2)),
            u_range=(-2,2),
            v_range=(-2,2),
            color=BLUE
        )
        
        surface_1 = OpenGLSurface(
            lambda u,v: (u, v, u**2 + v**2),
            u_range=(-2,2),
            v_range=(-2,2),
            color=PINK
        )
        
        self.camera.set_euler_angles(theta=0*DEGREES,phi=40*DEGREES,gamma=0*DEGREES)
        self.play(Create(surface))
        self.play(Transform(surface,surface_1),run_time=3)
        self.play(surface.animate.shift(np.array((0.0, 0.0, -3.0))))
        
        self.interactive_embed()
        
with tempconfig({"renderer": "opengl","enable_gui":True,"write_to_movie":False}):
    scene = TestOpenGL()
    scene.render()
launch.json configuration
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Manim File",
            "type": "debugpy",
            "request": "launch",
            "module": "manim",
            "args": ["${file}"],
            "console": "integratedTerminal",
        }
    ]
}

System specifications

System Details
  • OS : Windows 11 Home Single Language version 23H2, build 22631.4317
  • RAM: 16GB
  • Python version: 3.12.7
  • Visual Studio Code version: 1.95.3
  • conda version: 23.7.4
  • Installed modules:
Package              Version
-------------------- -------------
asttokens            2.0.5
backcall             0.2.0
black                24.10.0
Brotli               1.1.0
build                1.2.2.post1
CacheControl         0.14.1
cairocffi            1.7.1
certifi              2024.8.30
cffi                 1.17.1
charset-normalizer   3.4.0
cleo                 2.1.0
click                8.1.7
click-default-group  1.2.4
cloup                3.0.5
colorama             0.4.6
colour               0.1.5
comm                 0.2.2
commonmark           0.9.1
crashtest            0.4.1
debugpy              1.8.8
decorator            5.1.1
distlib              0.3.9
dulwich              0.21.3
executing            0.8.3
fastjsonschema       2.20.0
ffmpeg               1.4
filelock             3.16.1
future               1.0.0
glcontext            3.0.0
h2                   4.1.0
hpack                4.0.0
hyperframe           6.0.1
idna                 3.10
importlib_metadata   8.5.0
importlib_resources  6.4.5
installer            0.7.0
ipykernel            6.29.5
ipython              8.27.0
isosurfaces          0.1.2
jaraco.classes       3.4.0
jedi                 0.19.1
jupyter_client       8.6.3
jupyter_core         5.7.2
keyring              24.3.1
manim                0.18.1
ManimPango           0.6.0
mapbox_earcut        1.0.1
markdown-it-py       3.0.0
matplotlib-inline    0.1.6
mdurl                0.1.2
moderngl             5.11.1
moderngl-window      2.4.1
more-itertools       10.5.0
msgpack              1.1.0
multipledispatch     0.6.0
mypy-extensions      1.0.0
nest_asyncio         1.6.0
networkx             3.4.2
numpy                1.26.4
packaging            24.2
pangocairocffi       0.4.0
pangocffi            0.8.0
parso                0.8.3
pathspec             0.12.1
pexpect              4.9.0
pickleshare          0.7.5
pillow               11.0.0
pip                  24.2
pkginfo              1.11.2
platformdirs         4.3.6
poetry               1.8.4
poetry-core          1.9.1
poetry-plugin-export 1.8.0
progressbar          2.5
prompt-toolkit       3.0.43
psutil               6.1.0
ptyprocess           0.7.0
pure-eval            0.2.2
pycairo              1.27.0
pycparser            2.22
pydub                0.25.1
pyglet               1.5.27
Pygments             2.18.0
pyproject_hooks      1.2.0
pyrr                 0.10.3
PySocks              1.7.1
python-dateutil      2.9.0
pywin32              307
pywin32-ctypes       0.2.3
PyYAML               6.0.2
pyzmq                26.2.0
RapidFuzz            3.10.1
requests             2.32.3
requests-toolbelt    1.0.0
rich                 13.9.4
scipy                1.14.1
screeninfo           0.8.1
setuptools           75.1.0
shellingham          1.5.4
six                  1.16.0
skia-pathops         0.8.0.post2
srt                  3.5.3
stack-data           0.2.0
svgelements          1.9.6
tomli                2.1.0
tomlkit              0.13.2
tornado              6.4.1
tqdm                 4.67.0
traitlets            5.14.3
trove-classifiers    2024.10.21.16
typing_extensions    4.12.2
urllib3              2.2.3
virtualenv           20.27.1
watchdog             6.0.0
wcwidth              0.2.13
wheel                0.44.0
win_inet_pton        1.1.0
zipp                 3.21.0
zstandard            0.23.0
@minhvt98
Copy link
Author

minhvt98 commented Nov 16, 2024

After investigating for a while, I think I've found the problem. It seems that manim is rendering twice, the first time in tempconfig and the second time after quitting the interactive mode.
I managed to work around the issue by changing the code and debug configuration a bit (there's still an awkward pause since manim still renders for the second time but there's no animation, however it's better than having an error message). Also I set the flags --dry_run and --force_window to disable output. Otherwise it would create a black png.

testgl.py
from manim import *
from manim.opengl import *

played = False

class TestOpenGL(Scene):
    def construct(self):
        global played
        # return if the animation is already played once
        if played:
            return        
        surface = OpenGLSurface(
            lambda u,v: (u, v, np.sqrt(u**2+v**2)),
            u_range=(-2,2),
            v_range=(-2,2),
            color=BLUE
        )
        
        surface_1 = OpenGLSurface(
            lambda u,v: (u, v, u**2 + v**2),
            u_range=(-2,2),
            v_range=(-2,2),
            color=PINK
        )
        
        self.camera.set_euler_angles(theta=0*DEGREES,phi=40*DEGREES,gamma=0*DEGREES)
        self.play(Create(surface))
        self.play(Transform(surface,surface_1),run_time=3)
        self.play(surface.animate.shift(np.array((0.0, 0.0, -3.0))))
        
        self.interactive_embed()
        played = True

with tempconfig({"renderer": "opengl","enable_gui":True}):
    scene = TestOpenGL()
    scene.render()
launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Manim File",
            "type": "debugpy",
            "request": "launch",
            "module": "manim",
            "args": ["${file}", "--dry_run","--force_window"],
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}

For manim cli I removed the tempconfig part and used the flags instead
manim --renderer=opengl --force_window testgl_cli.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant