dm_control icon indicating copy to clipboard operation
dm_control copied to clipboard

Crash on macOS with matplotlib and dm_control.suite

Open camall3n opened this issue 5 years ago • 1 comments

I'm seeing a crash with the following program:

import matplotlib.pyplot as plt
from dm_control import suite

plt.plot()
plt.show()

If I disable the dm_control import, or if I import dm_control without importing suite, the empty figure displays normally.

If I leave it as-is, I get the following error:

2020-09-21 09:26:23.494 Python[24974:1597019] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7fa5e2974e80
2020-09-21 09:26:23.496 Python[24974:1597019] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fa5e2974e80'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff344e1acd __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff5ebe5a17 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff3455b8d6 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00007fff3448393f ___forwarding___ + 1485
	4   CoreFoundation                      0x00007fff344832e8 _CF_forwarding_prep_0 + 120
	5   Tk                                  0x00007fff4026e7d8 TkpInit + 466
	6   Tk                                  0x00007fff401edb86 Tk_Init + 1706
[...]
	54  Python                              0x000000010b315d0b _PyEval_EvalFrameDefault + 6576
	55  Python                              0x000000010b31d7a6 _PyEval_EvalCodeWithName + 1870
	56  Python                              0x000000010b2876e5 _PyFunction_FastCallDict + 441
	57  Python                              0x000000010b35a35c pymain_run_module + 147
	58  Python                              0x000000010b3593f5 pymain_main + 4196
	59  Python                              0x000000010b359f80 _Py_UnixMain + 56
	60  libdyld.dylib                       0x00007fff603b43d5 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

I'm running Python 3.7.4 on MacOS 10.14.6 and pip list shows the following versions:

dm-control             0.0.322773188
dm-env                 1.2
dm-tree                0.1.5
matplotlib             3.3.2

Seems related to issues #62 and #80.

camall3n avatar Sep 21 '20 13:09 camall3n

I found a workaround. Opening and closing a plot before importing dm_control.suite seems to prevent the crash.

import matplotlib.pyplot as plt
plt.plot()
plt.close()
from dm_control import suite

plt.plot()
plt.show()

This displays the empty figure and waits for the user to close it as expected.

camall3n avatar Sep 22 '20 13:09 camall3n