Open jafny opened 2 years ago
hi @jafny -- i'm exited to hear that you're trying to run ambit on mac. i haven't tried this yet and don't have the hardware to test, but happy to try to help out.
it looks like this error originates in pygame somewhere. it might be worth trying to run some simple pygame examples on your M1 and see if those work. could you do that and let me know your experience? as an example: https://github.com/pygame/pygame/blob/main/examples/scaletest.py
it may be that a newer or older version of pygame could also work better. could you include the output of python3 -m pip show pygame
to help troubleshoot?
Thanks for the prompt response! Here is the output Name: pygame Version: 2.0.3.dev3 Summary: Python Game Development Home-page: https://www.pygame.org Author: A community project. Author-email: pygame@pygame.org License: LGPL Location: /opt/homebrew/lib/python3.9/site-packages/pygame-2.0.3.dev3-py3.9-macosx-11-arm64.egg Requires: Required-by:
I gave it a try on an Ubuntu VM running on ARM it worked straight out of the gate with the newest version, so maybe this is something solely MacOS on ARM specific. My end environment would be ARM Linux anyway so I'm effectively unblocked but happy to help troubleshoot if you are looking to add support.
i'm still interested in understanding the cause of the failure, but it sounds like it isn't a high priority right now.
would you mind providing the information i requested above for posterity?
it may be that a newer or older version of pygame could also work better. could you include the output of
python3 -m pip
show pygame to help troubleshoot?
Sure, here it is:
Name: pygame Version: 2.0.3.dev3 Summary: Python Game Development Home-page: https://www.pygame.org Author: A community project. Author-email: pygame@pygame.org License: LGPL Location: /opt/homebrew/lib/python3.9/site-packages/pygame-2.0.3.dev3-py3.9-macosx-11-arm64.egg Requires: Required-by:
Hello, I'm also in the same situation on my mac (not m1 but I have also an m1 to test if you need it)
I install ambit like follow:
$ python3 -m pip install ambit
$ python3 -m pip install pyusb pygame numpy
Then I start the simulator:
ambit_simulator --verbose
result:
F] Device.__init__() DEAD:BEEF XYZ
[F] Device.open()
[0] Waiting for initial layout ...
[0] Component attached: Base (1) 00000 (0, 0) - 0 - False ::
[0] Component attached: Dial (2) C4@ (0, -1) - 0 - False ::
[0] Component attached: Dial (3) D5o (1, -1) - 270 - False ::
[0] Component attached: Button (4) B$; (1, 0) - 180 - False ::
[0] Component attached: Button (5) 8S$ (1, 1) - 180 - False ::
[0] Component attached: Dial (6) 6pZ (0, -2) - 0 - False ::
[0] Component attached: Dial (7) 6RD (-1, -1) - 90 - False ::
[0] Component attached: Button (8) 8a4 (-1, 0) - 180 - False ::
[0] Component attached: Slider (9) 8W( (-2, 0) - 90 - True ::
[0] Component attached: Slider (10) 8V$ (-2, -2) - 0 - False ::
[0] Component attached: Slider (11) Ak~ (2, -1) - 270 - False ::
[0] Component attached: Dial (12) 6om (2, 1) - 180 - False ::
[0] Component attached: Slider (13) 8Uq (1, -2) - 0 - False ::
[0] Component attached: Button (14) 8R+ (-1, 1) - 180 - False ::
[0] Component attached: Dial (15) 6J@ (-2, 1) - 90 - False ::
[0] Processed layout, ready for input!
[0] Detected Palette firmware version 1.3.1
[!] WARNING: image input had extra bytes 8190
2022-01-11 15:59:23.609 Python[31947:1998398] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff395824d7 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff720fb5bf objc_exception_throw + 48
2 AppKit 0x00007fff36778995 +[NSEvent _discardTrackingAndCursorEventsIfNeeded] + 0
3 libSDL2-2.0.0.dylib 0x00000001035b28bd Cocoa_PumpEvents + 125
4 libSDL2-2.0.0.dylib 0x00000001034f22c1 SDL_PumpEvents_REAL + 33
5 event.cpython-39-darwin.so 0x00000001037e95ca pg_event_poll + 42
6 Python 0x0000000102bed882 cfunction_vectorcall_NOARGS + 104
7 Python 0x0000000102ca039f call_function + 164
8 Python 0x0000000102c9dc71 _PyEval_EvalFrameDefault + 45331
9 Python 0x0000000102ba326c _PyFunction_Vectorcall + 192
10 Python 0x0000000102ca039f call_function + 164
11 Python 0x0000000102c9dbd4 _PyEval_EvalFrameDefault + 45174
12 Python 0x0000000102ba326c _PyFunction_Vectorcall + 192
13 Python 0x0000000102ba5feb method_vectorcall + 481
14 Python 0x0000000102c9dea9 _PyEval_EvalFrameDefault + 45899
15 Python 0x0000000102ba326c _PyFunction_Vectorcall + 192
16 Python 0x0000000102ca039f call_function + 164
17 Python 0x0000000102c9dbd4 _PyEval_EvalFrameDefault + 45174
18 Python 0x0000000102ba326c _PyFunction_Vectorcall + 192
19 Python 0x0000000102ca039f call_function + 164
20 Python 0x0000000102c9dbd4 _PyEval_EvalFrameDefault + 45174
21 Python 0x0000000102ba326c _PyFunction_Vectorcall + 192
22 Python 0x0000000102ba5feb method_vectorcall + 481
23 Python 0x0000000102d5ce4b t_bootstrap + 119
24 Python 0x0000000102d0210f pythread_wrapper + 36
25 libsystem_pthread.dylib 0x00007fff734a8109 _pthread_start + 148
26 libsystem_pthread.dylib 0x00007fff734a3b8b thread_start + 15
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1] 31947 abort ambit_simulator --verbose
For pygame version:
Name: pygame
Version: 2.1.2
Summary: Python Game Development
Home-page: https://www.pygame.org
Author: A community project.
Author-email: pygame@pygame.org
License: LGPL
Location: /usr/local/lib/python3.9/site-packages
Requires:
Required-by:
Happy to help is needed :D
hi @mazerte thank you for the details! could you try installing pygame==1.9.6
and see if that helps? currently, that is what ambit is pinned to in requirements.txt
and i haven't tested with more recent versions of pygame (especially 2.x).
A bit are to test on my mac because pygame
1.9.6
wasn't pre-compiled for python3.9
so I switch to python3.8
.
Seems to produce the same result:
[F] Device.__init__() DEAD:BEEF XYZ
[F] Device.open()
[0] Waiting for initial layout ...
[0] Component attached: Base (1) 00000 (0, 0) - 0 - False ::
[0] Component attached: Dial (2) C4@ (0, -1) - 0 - False ::
[0] Component attached: Dial (3) D5o (1, -1) - 270 - False ::
[0] Component attached: Button (4) B$; (1, 0) - 180 - False ::
[0] Component attached: Button (5) 8S$ (1, 1) - 180 - False ::
[0] Component attached: Dial (6) 6pZ (0, -2) - 0 - False ::
[0] Component attached: Dial (7) 6RD (-1, -1) - 90 - False ::
[0] Component attached: Button (8) 8a4 (-1, 0) - 180 - False ::
[0] Component attached: Slider (9) 8W( (-2, 0) - 90 - True ::
[0] Component attached: Slider (10) 8V$ (-2, -2) - 0 - False ::
[0] Component attached: Slider (11) Ak~ (2, -1) - 270 - False ::
[0] Component attached: Dial (12) 6om (2, 1) - 180 - False ::
[0] Component attached: Slider (13) 8Uq (1, -2) - 0 - False ::
[0] Component attached: Button (14) 8R+ (-1, 1) - 180 - False ::
[0] Component attached: Dial (15) 6J@ (-2, 1) - 90 - False ::
[0] Processed layout, ready for input!
[0] Detected Palette firmware version 1.3.1
Unable to obtain graphics context for NSWindow (Mojave behavior)
[!] WARNING: image input had extra bytes 8190
2022-01-12 00:01:12.579 Python[9483:2557588] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff395824d7 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff720fb5bf objc_exception_throw + 48
2 AppKit 0x00007fff36778995 +[NSEvent _discardTrackingAndCursorEventsIfNeeded] + 0
3 libSDL-1.2.0.dylib 0x000000010ecd3244 QZ_PumpEvents + 339
4 libSDL-1.2.0.dylib 0x000000010ecb50a8 SDL_PumpEvents + 37
5 libSDL-1.2.0.dylib 0x000000010ecb50db SDL_PollEvent + 14
6 event.cpython-38-darwin.so 0x000000010ee307a0 pg_event_poll + 32
7 Python 0x000000010e464c03 cfunction_vectorcall_NOARGS + 207
8 Python 0x000000010e4d6d1d call_function + 346
9 Python 0x000000010e4d38f7 _PyEval_EvalFrameDefault + 29861
10 Python 0x000000010e436742 function_code_fastcall + 106
11 Python 0x000000010e4d6d1d call_function + 346
12 Python 0x000000010e4d38db _PyEval_EvalFrameDefault + 29833
13 Python 0x000000010e436742 function_code_fastcall + 106
14 Python 0x000000010e438870 method_vectorcall + 256
15 Python 0x000000010e436189 PyVectorcall_Call + 108
16 Python 0x000000010e4d3c74 _PyEval_EvalFrameDefault + 30754
17 Python 0x000000010e436742 function_code_fastcall + 106
18 Python 0x000000010e4d6d1d call_function + 346
19 Python 0x000000010e4d38db _PyEval_EvalFrameDefault + 29833
20 Python 0x000000010e436742 function_code_fastcall + 106
21 Python 0x000000010e4d6d1d call_function + 346
22 Python 0x000000010e4d38db _PyEval_EvalFrameDefault + 29833
23 Python 0x000000010e436742 function_code_fastcall + 106
24 Python 0x000000010e438870 method_vectorcall + 256
25 Python 0x000000010e436189 PyVectorcall_Call + 108
26 Python 0x000000010e54cdc8 t_bootstrap + 74
27 Python 0x000000010e50e38e pythread_wrapper + 25
28 libsystem_pthread.dylib 0x00007fff734a8109 _pthread_start + 148
29 libsystem_pthread.dylib 0x00007fff734a3b8b thread_start + 15
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1] 9483 abort ambit_simulator --verbose
a few ideas to try:
1) i see they solved it by installing a dev version of pygame. have you tried that? pip install pygame==2.0.0.dev6
2) are you able to run any of the pygame examples i linked above,such as https://github.com/pygame/pygame/blob/main/examples/scaletest.py ?
3) there are some instructions here https://www.pygame.org/wiki/GettingStarted#Mac%20installation
4) i see some places suggesting it might help to install the right libraries with homebrew, eg. brew install sdl sdl_image sdl_mixer sdl_ttf portmidi smpeg
thank you for trying to help resolve the issue.
i see they solved it by installing a dev version of pygame. have you tried that? pip install pygame==2.0.0.dev6
Didn't work better
are you able to run any of the pygame examples i linked above,such as https://github.com/pygame/pygame/blob/main/examples/scaletest.py ?
Yes work fine with 1.9.6
, 2.0.0.dev6
and 2.1.2
there are some instructions here https://www.pygame.org/wiki/GettingStarted#Mac%20installation
Yes I follow these but nothing
i see some places suggesting it might help to install the right libraries with homebrew, eg. brew install sdl sdl_image sdl_mixer sdl_ttf portmidi smpeg
Yes library was missing on my first try and I install these to make it compile but it and up with the error above
I try the example here: https://stackoverflow.com/questions/68225235/unable-to-obtain-graphics-context-for-nswindow-mojave-behavior-pygame
And it works
From my searches and understanding (I have basic Python knowledge and never play with pygame
...), it seems that your are rending the interface outside the main thread -> https://github.com/khimaros/ambit/blob/b5f110114a274bbac22309a8f38a2baf39c1e60d/ambit/render.py#L244
I found this issue on deepmind/pysc2
https://github.com/deepmind/pysc2/issues/2 that was fixed by this PR https://github.com/deepmind/pysc2/pull/17
I hope it helps
Hello,
I am exited to play with this tool and see what it can do! I tried to launch the simulator in verbose mode after installation on my M1 Macbook, and got this error. Could it be a compatability issue?:
2022-01-06 15:34:51.690 Python[24700:1226509] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!' *** First throw call stack: ( 0 CoreFoundation 0x000000018ea5f838 __exceptionPreprocess + 240 1 libobjc.A.dylib 0x000000018e7890a8 objc_exception_throw + 60 2 AppKit 0x00000001911d0ae0 +[NSEvent _discardTrackingAndCursorEventsIfNeeded] + 0 3 libSDL2-2.0.0.dylib 0x0000000103777b74 Cocoa_PumpEventsUntilDate + 100 4 libSDL2-2.0.0.dylib 0x0000000103777cb0 Cocoa_PumpEvents + 52 5 libSDL2-2.0.0.dylib 0x00000001036f7f00 SDL_PumpEvents_REAL + 40 6 event.cpython-39-darwin.so 0x00000001039a03e0 pg_event_poll + 48 7 Python 0x0000000102f07a6c cfunction_vectorcall_NOARGS + 96 8 Python 0x0000000102fb265c call_function + 128 9 Python 0x0000000102fabf78 _PyEval_EvalFrameDefault + 22764 10 Python 0x0000000102eb85e8 _PyFunction_Vectorcall + 180 11 Python 0x0000000102fb265c call_function + 128 12 Python 0x0000000102fab218 _PyEval_EvalFrameDefault + 19340 13 Python 0x0000000102eb85e8 _PyFunction_Vectorcall + 180 14 Python 0x0000000102ebb158 method_vectorcall + 388 15 Python 0x0000000102fa6f28 _PyEval_EvalFrameDefault + 2204 16 Python 0x0000000102eb85e8 _PyFunction_Vectorcall + 180 17 Python 0x0000000102fb265c call_function + 128 18 Python 0x0000000102fab218 _PyEval_EvalFrameDefault + 19340 19 Python 0x0000000102eb85e8 _PyFunction_Vectorcall + 180 20 Python 0x0000000102fb265c call_function + 128 21 Python 0x0000000102fab218 _PyEval_EvalFrameDefault + 19340 22 Python 0x0000000102eb85e8 _PyFunction_Vectorcall + 180 23 Python 0x0000000102ebb158 method_vectorcall + 388 24 Python 0x0000000103069358 t_bootstrap + 120 25 Python 0x000000010300a818 pythread_wrapper + 48 26 libsystem_pthread.dylib 0x000000018e8e3878 _pthread_start + 320 27 libsystem_pthread.dylib 0x000000018e8de5e0 thread_start + 8 ) libc++abi: terminating with uncaught exception of type NSException