ManimCommunity / ManimCommunity/manim

Error when using `next_to` to a ImageMobject with the OpenGL renderer

Open
#3,722 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

Using the function `next_to` an ImageMObject using the OpenGL renderer causes an unexpected crash,
while it does works without issue with the cairo renderer.

## How to reproduce the issue

Using the following code in file `test.py` with the command ` manim -ql --renderer=opengl test.py ErrorAnimation`

```py
from manim import Scene, ImageMobject, FadeIn, Text, Write

class ErrorAnimation(Scene):

def construct(self):
image = ImageMobject("dummy.png")
label = Text("Label").next_to(image)
self.play(FadeIn(image))
self.play(Write(label))
```

## Logs
Terminal output

```╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/Azervivi/Programmation/Manim/manim/lib/python3.11/site-packages/manim/cli/render/commands. │
│ py:97 in render │
│ │
│ 94 │ │ │ │ for SceneClass in scene_classes_from_file(file): │
│ 95 │ │ │ │ │ with tempconfig({}): │
│ 96 │ │ │ │ │ │ scene = SceneClass(renderer) │
│ ❱ 97 │ │ │ │ │ │ rerun = scene.render() │
│ 98 │ │ │ │ │ if rerun or config["write_all"]: │
│ 99 │ │ │ │ │ │ renderer.num_plays = 0 │
│ 100 │ │ │ │ │ │ continue │
│ │
│ /home/Azervivi/Programmation/Manim/manim/lib/python3.11/site-packages/manim/scene/scene.py:223 │
│ in render │
│ │
│ 220 │ │ """ │
│ 221 │ │ self.setup() │
│ 222 │ │ try: │
│ ❱ 223 │ │ │ self.construct() │
│ 224 │ │ except EndSceneEarlyException: │
│ 225 │ │ │ pass │
│ 226 │ │ except RerunSceneException as e: │
│ │
│ /home/Azervivi/Programmation/Manim/test.py:7 in construct │
│ │
│ 4 │ │
│ 5 │ def construct(self): │
│ 6 │ │ image = ImageMobject("dummy.png") │
│ ❱ 7 │ │ label = Text("Label").next_to(image) │
│ 8 │ │ self.play(FadeIn(image)) │
│ 9 │ │ self.play(Write(label)) │
│ 10 │
│ │
│ /home/Azervivi/Programmation/Manim/manim/lib/python3.11/site-packages/manim/mobject/opengl/openg │
│ l_mobject.py:1730 in next_to │
│ │
│ 1727 │ │ else: │
│ 1728 │ │ │ aligner = self │
│ 1729 │ │ point_to_align = aligner.get_bounding_box_point(aligned_edge - direction) │
│ ❱ 1730 │ │ self.shift((target_point - point_to_align + buff * direction) * coor_mask) │
│ 1731 │ │ return self │
│ 1732 │ │
│ 1733 │ def shift_onto_screen(self, **kwargs): │
│ │
│ /home/Azervivi/Programmation/Manim/manim/lib/python3.11/site-packages/manim/mobject/mobject.py:5 │
│ 65 in __sub__ │
│ │
│ 562 │ │ return self │
│ 563 │ │
│ 564 │ def __sub__(self, other): │
│ ❱ 565 │ │ raise NotImplementedError │
│ 566 │ │
│ 567 │ def __isub__(self, other): │
│ 568 │ │ raise NotImplementedError │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
NotImplementedError
```

## System specifications

System Details

- OS Arch Linux 6.8.6-arch1-1
- RAM: 48Go
- Python version (`python/py/python3 --version`): Python 3.11.8
- Installed modules (provide output from `pip list`):
```
Package Version
------------------- ------------
certifi 2024.2.2
charset-normalizer 3.3.2
click 8.1.7
click-default-group 1.2.4
cloup 2.1.2
decorator 5.1.1
glcontext 2.5.0
idna 3.7
isosurfaces 0.1.0
manim 0.18.0.post0
ManimPango 0.5.0
mapbox-earcut 1.0.1
markdown-it-py 3.0.0
mdurl 0.1.2
moderngl 5.10.0
moderngl-window 2.4.4
multipledispatch 1.0.0
networkx 3.2.1
numpy 1.26.4
Pillow 9.5.0
pip 24.0
pycairo 1.26.0
pydub 0.25.1
pyglet 2.1.dev2
Pygments 2.17.2
pyrr 0.10.3
requests 2.31.0
rich 13.7.1
scipy 1.13.0
screeninfo 0.8.1
setuptools 69.2.0
skia-pathops 0.7.4
srt 3.5.3
svgelements 1.9.6
tqdm 4.66.2
typing_extensions 4.11.0
urllib3 2.2.1
watchdog 3.0.0
wheel 0.43.0
```

## Additional comments

The issue alsos occurs when using the `experimental` branch.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with test.py using `manim -ql --renderer=opengl test.py ErrorAnimation`. Then inspect `manim/mobject/opengl/opengl_mobject.py` around `next_to` and `manim/mobject/mobject.py` around `__sub__`; done means the example renders with the OpenGL renderer and the regression is covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.