-
Notifications
You must be signed in to change notification settings - Fork 648
Weird issue #220
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
Comments
Maybe this article is helpful: http://nshipster.com/nsundomanager/ |
The second time, my code to coerce OS X into thinking any thread other than the very first one created by the OS is main isn't working for some reason. This code is needed because OS X is dumb and cares about which thread was the first one created by the OS for no justifiable reason. I don't know why it isn't working the second time. I do know if you want a proper fix without the need for undocumented functions and hacks it will need to be taken up with the Go team. Also I thought I locked the wiki to prevent outside edits. |
So this is a Go issue? What is the go specific issue so I can file a bug report |
I don't know what the existing issue is an issue with. What I meant is that I do know that the correct, non-undocumented-call-workaround fix has to be done on the Go side: provide a way to lock a single goroutine and/or its cgo calls to |
I'm primarily an iOS developer (which is similar to macOS). If we need code to run on the main thread, we can check it using: https://developer.apple.com/reference/foundation/thread and https://developer.apple.com/reference/foundation/thread/1408455-ismainthread Could that be relevant for testing or atleast checking before running |
Also GCD: https://www.raywenderlich.com/60749/grand-central-dispatch-in-depth-part-1 has a function where you can call code guaranteed to be on main thread: |
You're thinking backwards: it's NSUndoManager that's using The problem is that OS X (and by extension iOS, watchOS, and tvOS) treats "the main thread" and "the first thread created by the OS when you fork() or start the program with Launch Services" as the same thing. On the other hand, on other systems, the main thread can be any thread you want, so long as you don't cross threads. I can spawn a thousand OS threads, then call Aside: there is a pthreads function This normally doesn't really matter for most programmers, except that the Go runtime does not guarantee that goroutines map 1:1 to OS threads. Goroutines can move around at will, as the scheduler optimizes things to run as efficiently as possible. It's entirely possible that by the time I did realize something while writing this: if you're starting a goroutine before calling And for what it's worth package ui is not the only package subject to this problem — all Go GUI packages that run on OS X are, including shiny. |
Thanks for the detailed reply. |
And are you running ui samples or your own code? |
ui samples |
I think the problem is with UI package:
|
That's an unrelated problem with a linking error in libui that will be fixed in the next stable-ish release. If that fix does fix this, then there are things about OS X that I do not understand... |
Ok, if you can, post here that you update to it test. Ok? |
may be you can read this question https://groups.google.com/forum/#!topic/golang-nuts/E_5-kZnXi5o |
Thanks, but I have considered that approach when it was first devised — I'd rather not require installing a separate framework or using I want to propose a As for the issue here, once I finally get the next libui out the door (whether it's an Alpha 0.3.1 with only a fix for a Windows bug or the Alpha 0.4) I can do more Heisenbug testing. |
Merged with #280 (which will also explain why the shiny examples worked). andlabs/libui#308 will fix the built for newer SDK version issue. |
I ran go get
github.com/andlabs/ui/
and then rango build .
for the code found here: https://github.com/andlabs/ui/wiki/Update-your-UI-in-other-goroutineThe first time I ran it, it worked beautifully.
I clicked the max os x red close button and the window closed. I could see in the terminal that the process shut down correctly.
When I ran the program again (same way as before), the program doesn't run anymore. It displays this error in terminal:
The text was updated successfully, but these errors were encountered: