3b1b / 3b1b/manim

Incorrect ImageMobject Content

Aperta
#2,145 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Python
Stelle
93.8k
Fork
7.7k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

### Describe the bug
When I create a large number of ImageMobjects, some of them get incorrectly set to another ImageMobject's image. There should be 35 green checkmarks & 7 red crosses. However, one of the green checkmarks is replaced by the 8th cross.

**Code**:
```python
from manimlib import *

# Files: green.png, red.png in same folder as this script

class MyScene(Scene):
def construct(self):
nodes = [ImageMobject(f"./green.png") for i in range(35)] + [ImageMobject(f"./red.png") for i in range(7)]
network = Group(*nodes).arrange_in_grid().scale(0.2)
self.add(network)
```

**Wrong display or Error traceback**:
![image](https://github.com/user-attachments/assets/f30ea767-6b11-4588-9dd0-a9ce6469c6c8)

### Additional context
When I run this code on my laptop, I still get the wrong amount of each picture, but the incorrect one is in a different spot in the grid.
![image_2024-07-16_02-54-07](https://github.com/user-attachments/assets/1fc3e57b-d1d7-47d3-a007-2176dae29eff)

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Look at the ImageMobject class in manimlib/mobject/types/image_mobject.py. The bug likely involves image caching or incorrect assignment when many instances are created. Run the provided script to reproduce the issue, then examine how images are loaded and stored. Check for shared references or mutable state. A test can be added to verify the fix ensures each ImageMobject displays the correct file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
computer-graphics
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.