Closed runrc closed 1 week ago
Thank you for reporting this. I am somewhat busy right now, but I will still be able to fix this soon (ideally within a few days, but definitely within a couple of weeks).
It appears that the cause of the race condition is the theoretical possibility that you could get one of those signals as the app is starting up, at which point AsyncLock
is not possible. Therefore, you can get rid of the race condition by putting your goroutine in OnShow
:
b.OnShow(func(e events.Event) {
go func() {
<-sigCh
// Caught user interrupt, shutting down.
b.AsyncLock()
core.TheApp.Quit()
b.AsyncUnlock()
}()
})
Please let me know if this fixes the issue.
Unfortunately, using the above code causes core.TheApp.Quit()
to hang in renderwindow.go
, func newRenderWindow()
, at line 120 whilst attempting to acquire rc.lock()
I fixed the underlying issue in #1309, so this should work now without any race conditions or hanging. You actually do not need to (and cannot) do AsyncLock
here, since Quit
already has the appropriate mutex protections. As such, this is the appropriate code for the relevant section:
b.OnShow(func(e events.Event) {
go func() {
<-sigCh
// Caught user interrupt, shutting down.
core.TheApp.Quit()
}()
})
Please let me know if that works for you.
Yes this works perfectly. Thank you.
Describe the bug
When attempting to close the main window using
system.TheApp.Quit()
from another goroutine (say a signal handler) causes a data race condition even when surrounded byAsyncLock() / AsyncUnlock()
How to reproduce
Call
system.TheApp.Quit()
from another goroutine.Example code
Relevant output
Platform
macOS