pyrender icon indicating copy to clipboard operation
pyrender copied to clipboard

[macos] run_in_thread=true doesn't work on macos

Open kyeshmz opened this issue 6 years ago • 11 comments

Hi I am using this awesome repo alongside trimesh, but the run_in_thread does not seem to work on macos. It seems to not work on the sample provided in the docs, and I get something like below.

My environment is 10.14.2 Mojave xcode 10.2 just in case.

2019-05-16 17:18:54.912 python[10096:8443809] *** 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                      0x00007fff2abf0ded __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff56cbc720 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff2ac0a87d -[NSException raise] + 9
	3   AppKit                              0x00007fff2810bc8e -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 324
	4   AppKit                              0x00007fff2810907c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1488
	5   AppKit                              0x00007fff28108aa6 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
	6   _ctypes.cpython-37m-darwin.so       0x000000010ebb8377 ffi_call_unix64 + 79
	7   ???                                 0x000070000c8c8460 0x0 + 123145512846432
)
libc++abi.dylib: terminating with uncaught exception of type NSException

kyeshmz avatar May 16 '19 08:05 kyeshmz

This isn't super surprising unfortunately, but I'm working on a fix. Will comment here when it's added.

mmatl avatar May 30 '19 15:05 mmatl

Hey sounds awesome, just looked at the windows version of this bug, seems more like a dependency problem with pyglet more than this wrapper itself

kyeshmz avatar Jun 25 '19 07:06 kyeshmz

This isn't super surprising unfortunately, but I'm working on a fix. Will comment here when it's added.

Any upate here? the run_in_thread still doesn't work on mac now? I saw the scissor example on the doc and want to do somthing similar.

laihaotao avatar Jul 21 '20 17:07 laihaotao

Checking in from the future. Any workarounds?

Mathemmagician avatar Nov 13 '21 19:11 Mathemmagician

Did anyone get this to work, @mmatl?

madsemildahlgaard avatar Apr 13 '22 14:04 madsemildahlgaard

The workaround is here, https://github.com/mmatl/pyrender/pull/213#issuecomment-1042971849

bakwc avatar Apr 30 '22 19:04 bakwc

The issue is that MacOS' Main Thread Checker will never allow UI kit to be run in a background thread. So run_in_thread=True is just flat-out impossible for MacOS Users. The long-term fix here is to make the UI thread run in the foreground while our tasks (Poses/Animations/Morph Targets, etc) run in the background. The Ability to disable auto-start PR is the correct approach. It (A) makes it so that you can declare a Viewer without immediately starting and halting your program while (B) acquiring and releasing the render lock even when run_in_thread is not true.

We should merge that PR into master, remove the run_in_thread param, and close this thread.

aelzeiny avatar May 02 '22 20:05 aelzeiny

@aelzeiny Yep, that's the long-term fix. I'll have something for this soon, hopefully, that fixes my original design mistake and allows you to schedule UI updates in callbacks without requiring locks at all.

mmatl avatar May 03 '22 00:05 mmatl

Any updates, it's been more than a year. Is the repository dead?

dslemusp avatar Aug 16 '23 22:08 dslemusp