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

Main thread #90

Closed
NightMan-1 opened this issue Jun 15, 2019 · 0 comments
Closed

Main thread #90

NightMan-1 opened this issue Jun 15, 2019 · 0 comments

Comments

@NightMan-1
Copy link

Hi!

I want run systray in separate thread, something like this:

go systray.Run(onReady, onExit)
fmt.Println("test1")
time.Sleep(10000 * time.Millisecond)
fmt.Println("test2")

All run as expected on Windows, but crash on MacOS:

bash-3.2$ go build && ./example
test1
2019-06-15 20:51:58.662 example[60748:2170198] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1575.12/Foundation/Misc.subproj/NSUndoManager.m:361
2019-06-15 20:51:58.663 example[60748:2170198] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff52e0ecfd __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff7d4b5a17 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff52e29a1a +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00007fff550c8c85 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
	4   Foundation                          0x00007fff54ffbcfa +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 473
	5   AppKit                              0x00007fff503d6915 -[NSApplication run] + 916
	6   example                             0x00000000042632e0 nativeLoop + 128
	7   example                             0x00000000042627ea _cgo_67d7e7d56c36_Cfunc_nativeLoop + 26
	8   example                             0x0000000004058aa0 runtime.asmcgocall + 112
)
libc++abi.dylib: terminating with uncaught exception of type NSException
SIGABRT: abort
PC=0x7fff7edbe2c6 m=6 sigcode=0
signal arrived during cgo execution

goroutine 18 [syscall, locked to thread]:
runtime.cgocall(0x42627d0, 0xc000030798, 0xc000076301)
	/usr/local/go/src/runtime/cgocall.go:128 +0x5b fp=0xc000030768 sp=0xc000030730 pc=0x4004f9b
github.com/getlantern/systray._Cfunc_nativeLoop(0x0)
	_cgo_gotypes.go:107 +0x49 fp=0xc000030798 sp=0xc000030768 pc=0x4260dd9
github.com/getlantern/systray.nativeLoop(...)
	/Users/nightman/go/src/github.com/getlantern/systray/systray_nonwindows.go:19
github.com/getlantern/systray.Run(0x430ed48, 0x430ed30)
	/Users/nightman/go/src/github.com/getlantern/systray/systray.go:81 +0x7f fp=0xc0000307d0 sp=0xc000030798 pc=0x426071f
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc0000307d8 sp=0xc0000307d0 pc=0x4059301
created by main.main
	/Users/nightman/Downloads/1/systray-master/example/main.go:21 +0x51

goroutine 1 [sleep]:
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:307
time.Sleep(0x2540be400)
	/usr/local/go/src/runtime/time.go:105 +0x159
main.main()
	/Users/nightman/Downloads/1/systray-master/example/main.go:23 +0xbd

goroutine 34 [chan receive]:
github.com/getlantern/systray.Run.func2(0xc00011c000, 0x430ed48)
	/Users/nightman/go/src/github.com/getlantern/systray/systray.go:66 +0x34
created by github.com/getlantern/systray.Run
	/Users/nightman/go/src/github.com/getlantern/systray/systray.go:65 +0xf1

rax    0x0
rbx    0x70000ac4b000
rcx    0x70000ac49488
rdx    0x0
rdi    0xb03
rsi    0x6
rbp    0x70000ac494c0
rsp    0x70000ac49488
r8     0x70000ac49350
r9     0x70000ac49520
r10    0x0
r11    0x206
r12    0xb03
r13    0x3000000008
r14    0x6
r15    0x2d
rip    0x7fff7edbe2c6
rflags 0x206
cs     0x7
fs     0x0
gs     0x0

Can you help?

@joesis joesis closed this as completed Jun 15, 2019
kszab0 added a commit to kszab0/lycurgus that referenced this issue Dec 9, 2020
On macOS the GUI (github.com/getlantern/systray) should be started on
the main thread. getlantern/systray#90
kszab0 added a commit to kszab0/lycurgus that referenced this issue Dec 10, 2020
On macOS the GUI (github.com/getlantern/systray) should be started on
the main thread. getlantern/systray#90
@getlantern getlantern deleted a comment from joesis Mar 1, 2021
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

2 participants