Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSInternalInconsistencyException When Using mjpython With composer.Environment on M1 Macbook #493

Open
RaedShabbir opened this issue Sep 14, 2024 · 1 comment

Comments

@RaedShabbir
Copy link

Hello,

In order to use mujoco.passive_viewer on my m1 macbook I have to use mjpython command to launch it.

But when I try to create an environment as follows

    env = composer.Environment(task=task, time_limit=time_limit, **env_kwargs)

Launching this with mjpython results in the following error

2024-09-14 14:15:19.365 mjpython[93348:387515] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001bfead198 __exceptionPreprocess + 240
	1   libobjc.A.dylib                     0x00000001bfbf7e04 objc_exception_throw + 60
	2   CoreFoundation                      0x00000001bfed8118 _CFBundleGetValueForInfoKey + 0
	3   AppKit                              0x00000001c29baba0 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 372
	4   AppKit                              0x00000001c29a5b9c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 948
	5   AppKit                              0x00000001c29a57dc -[NSWindow initWithContentRect:styleMask:backing:defer:] + 56
	6   libglfw.3.dylib                     0x00000001052ad710 _glfwPlatformCreateWindow + 336
	7   libglfw.3.dylib                     0x00000001052a7bc8 glfwCreateWindow + 332
	8   libffi.8.dylib                      0x000000010499004c ffi_call_SYSV + 76
	9   libffi.8.dylib                      0x000000010498d74c ffi_call_int + 1208
	10  _ctypes.cpython-310-darwin.so       0x0000000104970a1c _ctypes_callproc + 1260
	11  _ctypes.cpython-310-darwin.so       0x000000010496acfc PyCFuncPtr_call + 1132
	12  python3.10                          0x0000000104e4b59c _PyObject_MakeTpCall + 612
	13  python3.10                          0x0000000104f3d5d8 call_function + 676
	14  python3.10                          0x0000000104f38e60 _PyEval_EvalFrameDefault + 24940
	15  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	16  python3.10                          0x0000000104f3d540 call_function + 524
	17  python3.10                          0x0000000104f39430 _PyEval_EvalFrameDefault + 26428
	18  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	19  python3.10                          0x0000000104e4edc0 method_vectorcall + 520
	20  python3.10                          0x0000000104f39658 _PyEval_EvalFrameDefault + 26980
	21  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	22  python3.10                          0x0000000104f3d540 call_function + 524
	23  python3.10                          0x0000000104f38e38 _PyEval_EvalFrameDefault + 24900
	24  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	25  python3.10                          0x0000000104e4ec64 method_vectorcall + 172
	26  python3.10                          0x0000000104f3d540 call_function + 524
	27  python3.10                          0x0000000104f38e60 _PyEval_EvalFrameDefault + 24940
	28  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	29  python3.10                          0x0000000104e4b7ac _PyObject_FastCallDictTstate + 156
	30  python3.10                          0x0000000104e4c454 _PyObject_Call_Prepend + 176
	31  python3.10                          0x0000000104ec3394 slot_tp_init + 116
	32  python3.10                          0x0000000104ebbd64 type_call + 456
	33  python3.10                          0x0000000104e4b59c _PyObject_MakeTpCall + 612
	34  python3.10                          0x0000000104f3d5d8 call_function + 676
	35  python3.10                          0x0000000104f39430 _PyEval_EvalFrameDefault + 26428
	36  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	37  python3.10                          0x0000000104f3d540 call_function + 524
	38  python3.10                          0x0000000104f38e38 _PyEval_EvalFrameDefault + 24900
	39  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	40  python3.10                          0x0000000104e57f80 property_descr_get + 128
	41  python3.10                          0x0000000104ea4a74 _PyObject_GenericGetAttrWithDict + 208
	42  python3.10                          0x0000000104ea548c PyObject_GetAttr + 96
	43  python3.10                          0x0000000104f3754c _PyEval_EvalFrameDefault + 18520
	44  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	45  python3.10                          0x0000000104e4b7ac _PyObject_FastCallDictTstate + 156
	46  python3.10                          0x0000000104e4c454 _PyObject_Call_Prepend + 176
	47  python3.10                          0x0000000104ec3394 slot_tp_init + 116
	48  python3.10                          0x0000000104ebbd64 type_call + 456
	49  python3.10                          0x0000000104e4b59c _PyObject_MakeTpCall + 612
	50  python3.10                          0x0000000104f3d5d8 call_function + 676
	51  python3.10                          0x0000000104f39430 _PyEval_EvalFrameDefault + 26428
	52  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	53  python3.10                          0x0000000104e4ec64 method_vectorcall + 172
	54  python3.10                          0x0000000104f3d540 call_function + 524
	55  python3.10                          0x0000000104f39430 _PyEval_EvalFrameDefault + 26428
	56  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	57  python3.10                          0x0000000104f3d540 call_function + 524
	58  python3.10                          0x0000000104f38e60 _PyEval_EvalFrameDefault + 24940
	59  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	60  python3.10                          0x0000000104f3d540 call_function + 524
	61  python3.10                          0x0000000104f38e38 _PyEval_EvalFrameDefault + 24900
	62  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	63  python3.10                          0x0000000104f3d540 call_function + 524
	64  python3.10                          0x0000000104f38e38 _PyEval_EvalFrameDefault + 24900
	65  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	66  python3.10                          0x0000000104e4ec64 method_vectorcall + 172
	67  python3.10                          0x0000000104f3d540 call_function + 524
	68  python3.10                          0x0000000104f39430 _PyEval_EvalFrameDefault + 26428
	69  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	70  python3.10                          0x0000000104e4b7ac _PyObject_FastCallDictTstate + 156
	71  python3.10                          0x0000000104e4c454 _PyObject_Call_Prepend + 176
	72  python3.10                          0x0000000104ec3394 slot_tp_init + 116
	73  python3.10                          0x0000000104ebbd64 type_call + 456
	74  python3.10                          0x0000000104e4bfb0 _PyObject_Call + 148
	75  python3.10                          0x0000000104f39658 _PyEval_EvalFrameDefault + 26980
	76  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	77  python3.10                          0x0000000104f3d540 call_function + 524
	78  python3.10                          0x0000000104f39430 _PyEval_EvalFrameDefault + 26428
	79  python3.10                          0x0000000104f32364 _PyEval_Vector + 2036
	80  python3.10                          0x0000000104f8d398 run_mod + 216
	81  python3.10                          0x0000000104f8ce38 _PyRun_SimpleFileObject + 1260
	82  python3.10                          0x0000000104f8be1c _PyRun_AnyFileObject + 240
	83  python3.10                          0x0000000104fb08f8 Py_RunMain + 2340
	84  mjpython                            0x000000010479e940 _ZN12_GLOBAL__N_115mjpython_pymainEPv + 160
	85  libsystem_pthread.dylib             0x00000001bfd6026c _pthread_start + 148
	86  libsystem_pthread.dylib             0x00000001bfd5b08c thread_start + 8
)
libc++abi: terminating with uncaught exception of type NSException
[1]    93348 abort      mjpython 

This only occurs when using mjpython, a requirement for my script, where I use the passive viewer to view and interact with the environment.

with mujoco.viewer.launch_passive(
            self._env.physics.model.ptr, self._env.physics.data.ptr, show_right_ui=False
        ) as viewer:
            while viewer.is_running():
                if self._reset_step:
                    ts = self._env.reset()
                    self._reset_step = False

                step_start = time.time()

                ts = self._env.step(self._joint_cmd)
                self._joint_state = ts.observation["joint_positions"]
                ... 
            
Would appreciate any workarounds or advice! 
@RaedShabbir
Copy link
Author

Specifically this seems to occur in dm_control/composer/observation/updater.py

    for enabled in self._enabled_list:
      first_delay = _call_if_callable(enabled.delay)
      enabled.buffer.insert(
          0, first_delay,
          enabled.observation_callable())

When we call enabled.observation_callable() for the following enabled

enabled
<dm_control.composer.observation.updater._EnabledObservable object at 0x13fabbf40>
function variables
buffer =
<dm_control.composer.observation.obs_buffer.Buffer object at 0x14912cc70>
buffer_size =
1
delay =
0
observable =
**<dm_control.composer.observation.observable.base.MujocoCamera object at 0x1481a5690>**
update_interval =
1
update_schedule =
deque([])
_bind_attribute_from_observable =
<bound method _EnabledObservable._bind_attribute_from_observable of <dm_control.composer.observation.updater._EnabledObservable object at 0x13fabbf40>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant