ManimCommunity / ManimCommunity/manim

Threading issue running gui on Mac OS

Open
#1,859 0 comments 0 reactions 0 assignees View on GitHub
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

When using the `enable_gui` flag on mac the gui window does not appear, the same runs scenario fine on windows.

It also outputs `2021-08-02 18:30:10.335 Python[32816:801404] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future`

The actual scene appears with no issues. It could be specific to mac as it says here that in mac UIs need to be called on the main thread - https://developer.apple.com/forums/thread/659010

## Expected behavior

The gui window to appear as it does in windows

## How to reproduce the issue

Code for reproducing the problem

Run opengl renderer with `--enable_gui` flag on mac os. I ran with the command `python -m manim ../scenes/playground.py --renderer opengl --enable_gui -p SphereTest`

```py
from manim import *

class SphereTest(Scene):
def construct(self):
a = Sphere()
self.play(Create(a))
self.interactive_embed()
```

## Additional media files

Images/GIFs

## Logs
Terminal output

```
Manim Community v0.8.0

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py:125: RuntimeWarning: 'manim.__main__' found in sys.modules after import of package 'manim', but prior to execution of 'manim.__main__'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
[08/02/21 18:30:04] DEBUG Hashing ... hashing.py:318
[08/02/21 18:30:05] DEBUG Hashing done in 1.100191 s. hashing.py:330
DEBUG Hash generated : hashing.py:333
1491410813_1760937233_3449842885
DEBUG List of the first few animation caching.py:56
hashes of the scene:
['1491410813_1760937233_3449842885']
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.24.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: 2021-08-02 18:30:10.335 Python[32816:801404] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
0 AppKit 0x00007fff22e2747f -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 352
1 AppKit 0x00007fff22e12121 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1375
2 AppKit 0x00007fff22e11bbb -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
3 core.so 0x00000001139b2417 createNativeWindow + 647
4 core.so 0x00000001139b1fe0 _glfwPlatformCreateWindow + 96
5 core.so 0x00000001139a7d22 glfwCreateWindow + 994
6 core.so 0x00000001135238ae _ZN6Marvel13mvAppleWindowC2Ejjb + 350
7 core.so 0x0000000113523712 _ZN6Marvel8mvWindow14CreatemvWindowEjjb + 50
8 core.so 0x00000001135537dd _ZN6Marvel5mvApp5startERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 45
9 core.so 0x000000011366ff4d _ZN6Marvel15start_dearpyguiEP7_objectS1_S1_ + 573
10 Python 0x00000001035b71dd _PyMethodDef_RawFastCallKeywords + 685
11 Python 0x00000001035b65da _PyCFunction_FastCallKeywords + 42
12 Python 0x00000001036758b4 call_function + 724
13 Python 0x000000010367288d _PyEval_EvalFrameDefault + 25181
14 Python 0x0000000103676413 _PyEval_EvalCodeWithName + 2467
15 Python 0x00000001035b617b _PyFunction_FastCallDict + 523
16 Python 0x0000000103672b9e _PyEval_EvalFrameDefault + 25966
17 Python 0x00000001035b6a10 function_code_fastcall + 128
18 Python 0x00000001036758c2 call_function + 738
19 Python 0x0000000103672873 _PyEval_EvalFrameDefault + 25155
20 Python 0x00000001035b6a10 function_code_fastcall + 128
21 Python 0x00000001036758c2 call_function + 738
22 Python 0x0000000103672873 _PyEval_EvalFrameDefault + 25155
23 Python 0x00000001035b6a10 function_code_fastcall + 128
24 Python 0x00000001035b6004 _PyFunction_FastCallDict + 148
25 Python 0x00000001035b74bf _PyObject_Call_Prepend + 143
26 Python 0x00000001035b6707 PyObject_Call + 135
27 Python 0x00000001036fdb77 t_bootstrap + 71
28 Python 0x00000001036b4939 pythread_wrapper + 25
29 libsystem_pthread.dylib 0x00007fff204e6950 _pthread_start + 224
30 libsystem_pthread.dylib 0x00007fff204e247b thread_start + 15
)
2021-08-02 18:30:10.375 Python[32816:801404] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
2021-08-02 18:31:28.596 Python[32816:801404] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x7fca8cdbff00> was mutated while being enumerated.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff206586af __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff203903c9 objc_exception_throw + 48
2 CoreFoundation 0x00007fff206d4213 __NSFastEnumerationMutationHandler + 151
3 core.so 0x000000011399b5af -[MetalContext dequeueReusableBufferOfLength:device:] + 911
4 core.so 0x000000011399cb57 -[MetalContext renderDrawData:commandBuffer:commandEncoder:] + 247
5 core.so 0x000000011399a629 _Z30ImGui_ImplMetal_RenderDrawDataP10ImDrawDataPU27objcproto16MTLCommandBuffer11objc_objectPU34objcproto23MTLRenderCommandEncoder11objc_object + 57
6 core.so 0x0000000113524771 _ZN6Marvel13mvAppleWindow11renderFrameEv + 929
7 core.so 0x0000000113524899 _ZN6Marvel13mvAppleWindow6renderEv + 25
8 core.so 0x0000000113553b50 _ZN6Marvel5mvApp5startERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 928
9 core.so 0x000000011366ff4d _ZN6Marvel15start_dearpyguiEP7_objectS1_S1_ + 573
10 Python 0x00000001035b71dd _PyMethodDef_RawFastCallKeywords + 685
11 Python 0x00000001035b65da _PyCFunction_FastCallKeywords + 42
12 Python 0x00000001036758b4 call_function + 724
13 Python 0x000000010367288d _PyEval_EvalFrameDefault + 25181
14 Python 0x0000000103676413 _PyEval_EvalCodeWithName + 2467
15 Python 0x00000001035b617b _PyFunction_FastCallDict + 523
16 Python 0x0000000103672b9e _PyEval_EvalFrameDefault + 25966
17 Python 0x00000001035b6a10 function_code_fastcall + 128
18 Python 0x00000001036758c2 call_function + 738
19 Python 0x0000000103672873 _PyEval_EvalFrameDefault + 25155
20 Python 0x00000001035b6a10 function_code_fastcall + 128
21 Python 0x00000001036758c2 call_function + 738
22 Python 0x0000000103672873 _PyEval_EvalFrameDefault + 25155
23 Python 0x00000001035b6a10 function_code_fastcall + 128
24 Python 0x00000001035b6004 _PyFunction_FastCallDict + 148
25 Python 0x00000001035b74bf _PyObject_Call_Prepend + 143
26 Python 0x00000001035b6707 PyObject_Call + 135
27 Python 0x00000001036fdb77 t_bootstrap + 71
28 Python 0x00000001036b4939 pythread_wrapper + 25
29 libsystem_pthread.dylib 0x00007fff204e6950 _pthread_start + 224
30 libsystem_pthread.dylib 0x00007fff204e247b thread_start + 15
)
libc++abi.dylib: terminating with uncaught exception of type NSException
```

## System specifications

System Details

- OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)): macOS Big Sur 11.2.3 (20D91)
- RAM: 8gb
- Python version (`python/py/python3 --version`): 3.7.4
- Installed modules (provide output from `pip list`):
```
appnope 0.1.2
argon2-cffi 20.1.0
arrow 0.17.0
async-generator 1.10
attrs 20.3.0
backcall 0.2.0
beautifulsoup4 4.9.3
bleach 3.3.0
cairocffi 1.2.0
certifi 2020.12.5
cffi 1.14.4
chardet 4.0.0
click 7.1.2
click-default-group 1.2.2
cloup 0.7.0
colorama 0.4.4
colour 0.1.5
commonmark 0.9.1
cycler 0.10.0
Cython 0.29.23
dearpygui 0.6.415
debugpy 1.3.0
decorator 5.0.9
defusedxml 0.7.1
entrypoints 0.3
ffprobe 0.5
glcontext 2.3.3
google 3.0.0
grpcio 1.38.1
idna 2.10
importlib-metadata 3.1.0
iniconfig 1.1.1
ipykernel 6.0.1
ipython 7.24.1
ipython-genutils 0.2.0
ipywidgets 7.6.3
jedi 0.18.0
Jinja2 2.11.2
jinja2-time 0.2.0
jsonschema 3.2.0
jupyter 1.0.0
jupyter-client 6.1.12
jupyter-console 6.4.0
jupyter-core 4.7.1
jupyterlab-pygments 0.1.2
jupyterlab-widgets 1.0.0
kiwisolver 1.3.1
make 0.1.6.post2
manim 0.8.0
manimce 0.1.0
ManimPango 0.3.0
mapbox-earcut 0.12.10
MarkupSafe 1.1.1
matplotlib 3.4.2
matplotlib-inline 0.1.2
mistune 0.8.4
moderngl 5.6.4
moderngl-window 2.3.0
multipledispatch 0.6.0
nbclient 0.5.3
nbconvert 6.1.0
nbformat 5.1.3
nest-asyncio 1.5.1
networkx 2.5
notebook 6.4.0
numpy 1.19.4
packaging 20.7
pandocfilters 1.4.3
pangocairocffi 0.4.0
pangocffi 0.8.0
parso 0.8.2
pexpect 4.8.0
pickleshare 0.7.5
Pillow 8.2.0
pip 20.3.3
pluggy 0.13.1
progressbar 2.5
prometheus-client 0.11.0
prompt-toolkit 3.0.18
protobuf 3.17.3
ptyprocess 0.7.0
py 1.9.0
pycairo 1.20.0
pycparser 2.20
pydub 0.24.1
pyglet 1.5.15
Pygments 2.7.2
pyobjc-core 7.3
pyobjc-framework-Cocoa 7.3
pyparsing 2.4.7
pyrr 0.10.3
pyrsistent 0.18.0
pytest 6.1.2
python-dateutil 2.8.1
pyzmq 22.1.0
qtconsole 5.1.1
QtPy 1.9.0
requests 2.25.1
rich 6.2.0
scipy 1.5.4
screeninfo 0.6.7
Send2Trash 1.7.1
setuptools 50.3.2
six 1.15.0
soupsieve 2.2.1
terminado 0.10.1
testpath 0.5.0
toml 0.10.2
tornado 6.1
tqdm 4.54.0
traitlets 5.0.5
typing-extensions 3.7.4.3
urllib3 1.26.4
watchdog 2.1.2
wcwidth 0.2.5
webencodings 0.5.1
widgetsnbextension 3.5.1
zipp 3.4.0

```

LaTeX details

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

FFMPEG

Output of `ffmpeg -version`:

```
PASTE HERE
```

## Additional comments

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with `python -m manim ../scenes/playground.py --renderer opengl --enable_gui -p SphereTest` and the provided `SphereTest` scene, focusing on `enable_gui` and `interactive_embed()`. Trace GUI startup and verify that the window appears on macOS without the main-thread warnings or termination shown in the logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, python
Domain
computer-graphics, desktop
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.