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

Event loop is not working anymore on macOS Sierra #50

Closed
szkrd opened this issue Nov 20, 2016 · 3 comments
Closed

Event loop is not working anymore on macOS Sierra #50

szkrd opened this issue Nov 20, 2016 · 3 comments

Comments

@szkrd
Copy link

szkrd commented Nov 20, 2016

Maybe I'm missing something: cloned the repo, npm i, npm start and I get an nsexception error. Tried to do a standalone hello world, but the same happened - I'm on OSX, Sierra, will give it a try on Arch too. Do I have to install something else, or is my node version unsupported?

szkurdi ~/Projects/sandbox/libui-node $ npm start

> libui-node@0.0.12 start /Users/szkurdi/Projects/sandbox/libui-node
> node examples/control-gallery.js

2016-11-20 20:29:38.703 node[6245:111927] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fffd538048b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00007fffe9ae2cad objc_exception_throw + 48
	2   AppKit                              0x00007fffd369350c -[NSApplication(NSEvent) shouldBeTreatedAsInkEvent:] + 0
	3   nbind.node                          0x00000001043bd801 _Z10pollEventsPv + 273
	4   libsystem_pthread.dylib             0x00007fffea5d8aab _pthread_body + 180
	5   libsystem_pthread.dylib             0x00007fffea5d89f7 _pthread_body + 0
	6   libsystem_pthread.dylib             0x00007fffea5d8221 thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
szkurdi ~/Projects/sandbox/libui-node $ node --version
v7.1.0
szkurdi ~/Projects/sandbox/libui-node $ uname -a
Darwin Szabolcss-Air 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64

Edit: yes, it works fine on Arch :)

@RockyF
Copy link

RockyF commented Apr 28, 2017

who to fix it?

@parro-it
Copy link
Owner

This is related to how the event loop is actually implemented by libui-node.

Actually, on macOS and linux libui-node spawn a background thread that does a blocking GUI system call to check if there is some GUI event pending. If there are any, it send a message to node main thread, that in turn process these events.

This blocking give libui-node a great speed boost compared to a polling one (that is still used on Windows), but it can on be done in a background thread.

This used to work until Yosemite, but after that Apple introduces a hard limitation that such a check for GUI event loop status can be done only in main thread.

There is a previous, more complicated implementation that used an undocumented macOS feature but work without background threads. I could try to restore it in next relase.

@parro-it parro-it changed the title nsexception error Event loop is not working anymore on macOS Sierra Feb 19, 2018
@mischnic
Copy link
Collaborator

Works now

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

4 participants