giu: [bug] examples/widgets broken on cimgui-go
What happend?
Failed to start with following error log.
2023-09-22 21:26:48.585 widgets[70477:6681227] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00000001824fb154 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x000000018201a4d4 objc_exception_throw + 60
2 AppKit 0x00000001856a7368 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2844
3 widgets 0x00000001050c9348 _glfwPlatformPollEvents + 152
4 widgets 0x00000001050c1b80 glfwPollEvents + 48
5 widgets 0x0000000104e58c88 igRunLoop + 252
6 widgets 0x0000000104d3646c runtime.asmcgocall.abi0 + 124
)
libc++abi: terminating due to uncaught exception of type NSException
SIGABRT: abort
PC=0x18236c764 m=5 sigcode=0
signal arrived during cgo execution
goroutine 35 [syscall]:
runtime.cgocall(0x104e4d6e4, 0x14000235ee8)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/cgocall.go:157 +0x44 fp=0x14000235eb0 sp=0x14000235e70 pc=0x104cd3cb4
github.com/AllenDang/cimgui-go._Cfunc_igRunLoop(0x142e4d090, 0x104e113f4, 0x104e11440, 0x104e1148c, 0x104e11524)
_cgo_gotypes.go:29012 +0x30 fp=0x14000235ee0 sp=0x14000235eb0 pc=0x104d8fcd0
github.com/AllenDang/cimgui-go.(*GLFWBackend).Run.func1(0x1?)
/Users/allen/go/pkg/mod/github.com/!allen!dang/cimgui-go@v0.0.0-20230918114712-675654f053d9/glfw_backend.go:251 +0xa4 fp=0x14000235f50 sp=0x14000235ee0 pc=0x104d98ac4
github.com/AllenDang/cimgui-go.(*GLFWBackend).Run(0x0?, 0x0?)
/Users/allen/go/pkg/mod/github.com/!allen!dang/cimgui-go@v0.0.0-20230918114712-675654f053d9/glfw_backend.go:251 +0x40 fp=0x14000235f70 sp=0x14000235f50 pc=0x104d989f0
main.main.(*MasterWindow).Run.func1()
/Users/allen/Documents/Gocode/src/github.com/AllenDang/giu/MasterWindow.go:241 +0xe4 fp=0x14000235fa0 sp=0x14000235f70 pc=0x104e10894
github.com/faiface/mainthread.Run.func1()
/Users/allen/go/pkg/mod/github.com/faiface/mainthread@v0.0.0-20171120011319-8b78f0a41ae3/mainthread.go:37 +0x30 fp=0x14000235fd0 sp=0x14000235fa0 pc=0x104dfe100
runtime.goexit()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/asm_arm64.s:1197 +0x4 fp=0x14000235fd0 sp=0x14000235fd0 pc=0x104d36674
created by github.com/faiface/mainthread.Run in goroutine 1
/Users/allen/go/pkg/mod/github.com/faiface/mainthread@v0.0.0-20171120011319-8b78f0a41ae3/mainthread.go:36 +0xbc
goroutine 1 [select, locked to thread]:
runtime.gopark(0x14000054ea8?, 0x2?, 0xa0?, 0x21?, 0x14000054e94?)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:398 +0xc8 fp=0x14000054d40 sp=0x14000054d20 pc=0x104d07a28
runtime.selectgo(0x14000054ea8, 0x14000054e90, 0x0?, 0x0, 0x2?, 0x1)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/select.go:327 +0x608 fp=0x14000054e50 sp=0x14000054d40 pc=0x104d181f8
github.com/faiface/mainthread.Run(0x1400011e318)
/Users/allen/go/pkg/mod/github.com/faiface/mainthread@v0.0.0-20171120011319-8b78f0a41ae3/mainthread.go:42 +0x110 fp=0x14000054ed0 sp=0x14000054e50 pc=0x104dfe0a0
github.com/AllenDang/giu.(*MasterWindow).Run(...)
/Users/allen/Documents/Gocode/src/github.com/AllenDang/giu/MasterWindow.go:233
main.main()
/Users/allen/Documents/Gocode/src/github.com/AllenDang/giu/examples/widgets/widgets.go:269 +0x170 fp=0x14000054f30 sp=0x14000054ed0 pc=0x104e10780
runtime.main()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:267 +0x2bc fp=0x14000054fd0 sp=0x14000054f30 pc=0x104d075fc
runtime.goexit()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/asm_arm64.s:1197 +0x4 fp=0x14000054fd0 sp=0x14000054fd0 pc=0x104d36674
goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:398 +0xc8 fp=0x14000044f90 sp=0x14000044f70 pc=0x104d07a28
runtime.goparkunlock(...)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:404
runtime.forcegchelper()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:322 +0xb8 fp=0x14000044fd0 sp=0x14000044f90 pc=0x104d078b8
runtime.goexit()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/asm_arm64.s:1197 +0x4 fp=0x14000044fd0 sp=0x14000044fd0 pc=0x104d36674
created by runtime.init.6 in goroutine 1
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:310 +0x24
goroutine 18 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:398 +0xc8 fp=0x14000040760 sp=0x14000040740 pc=0x104d07a28
runtime.goparkunlock(...)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:404
runtime.bgsweep(0x0?)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mgcsweep.go:280 +0xa0 fp=0x140000407b0 sp=0x14000040760 pc=0x104cf3840
runtime.gcenable.func1()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mgc.go:200 +0x28 fp=0x140000407d0 sp=0x140000407b0 pc=0x104ce85a8
runtime.goexit()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/asm_arm64.s:1197 +0x4 fp=0x140000407d0 sp=0x140000407d0 pc=0x104d36674
created by runtime.gcenable in goroutine 1
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mgc.go:200 +0x6c
goroutine 19 [GC scavenge wait]:
runtime.gopark(0x1400008e000?, 0x105124ee0?, 0x1?, 0x0?, 0x140000824e0?)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:398 +0xc8 fp=0x14000040f50 sp=0x14000040f30 pc=0x104d07a28
runtime.goparkunlock(...)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:404
runtime.(*scavengerState).park(0x1052f8fa0)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mgcscavenge.go:425 +0x5c fp=0x14000040f80 sp=0x14000040f50 pc=0x104cf10bc
runtime.bgscavenge(0x0?)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mgcscavenge.go:653 +0x44 fp=0x14000040fb0 sp=0x14000040f80 pc=0x104cf1614
runtime.gcenable.func2()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mgc.go:201 +0x28 fp=0x14000040fd0 sp=0x14000040fb0 pc=0x104ce8548
runtime.goexit()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/asm_arm64.s:1197 +0x4 fp=0x14000040fd0 sp=0x14000040fd0 pc=0x104d36674
created by runtime.gcenable in goroutine 1
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mgc.go:201 +0xac
goroutine 34 [finalizer wait]:
runtime.gopark(0x8?, 0x10518a880?, 0x1?, 0x45?, 0x104d450e4?)
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/proc.go:398 +0xc8 fp=0x14000044580 sp=0x14000044560 pc=0x104d07a28
runtime.runfinq()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mfinal.go:193 +0x108 fp=0x140000447d0 sp=0x14000044580 pc=0x104ce7698
runtime.goexit()
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/asm_arm64.s:1197 +0x4 fp=0x140000447d0 sp=0x140000447d0 pc=0x104d36674
created by runtime.createfing in goroutine 1
/opt/homebrew/Cellar/go/1.21.1/libexec/src/runtime/mfinal.go:163 +0x80
r0 0x0
r1 0x0
r2 0x0
r3 0x0
r4 0x182360647
r5 0x16d151c80
r6 0x6e
r7 0x3
r8 0xb7c7c141955a3bf8
r9 0xb7c7c140f84f0bf8
r10 0x200
r11 0xb
r12 0xb
r13 0x1ff800
r14 0x7fb
r15 0x85635016
r16 0x148
r17 0x1e1f4b3a0
r18 0x0
r19 0x6
r20 0x16d153000
r21 0x1803
r22 0x16d1530e0
r23 0x600000008f00
r24 0xffffffffffffffff
r25 0x133828048
r26 0x1400011e318
r27 0x1
r28 0x140000031e0
r29 0x16d151bf0
lr 0x1823a3c28
sp 0x16d151bd0
pc 0x18236c764
fault 0x18236c764
exit status 2
Code example
main.go
// put your code here!
To Reproduce
- Update master branch to lasted.
- cd to examples/widgets
- Invoke
go run .
- will see the crash…
Version
master
OS
macOS v13.5.2
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 1
- Comments: 15 (1 by maintainers)
Commits related to this issue
- change mainthread library should fix #700 because it fixes mainthread handling for macos — committed to gucio321/giu by gucio321 9 months ago
yes so its #716. This is fixed.
@AllenDang @voladelta should work now. Sorry for delay but still don’t have any computer dedicated for effective development
@AllenDang @voladelta could you try https://github.com/AllenDang/giu/pull/706 on macos
Will try to test here in fedora now.
@voladelta thank you for your really valuale info! At the moment we use some mainthread library. I need to check its usage there…