mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/uidriver/glfw: Bug fix: Deadlock at FramebufferSize callback
glfw.PollEvents might invoke multiple FramebufferSize callbacks in theory, this is very rare though. In this case, the sending an object to the channel never ends. This change fixes this deadlock by using 'select'. Closes #1618
This commit is contained in:
parent
875670382d
commit
1b33d11d4a
@ -1039,7 +1039,12 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
|
||||
if oldW != newW || oldH != newH {
|
||||
ch := make(chan struct{}, 1)
|
||||
u.window.SetFramebufferSizeCallback(func(_ *glfw.Window, _, _ int) {
|
||||
ch <- struct{}{}
|
||||
// This callback can be invoked multiple times by one PollEvents in theory (#1618).
|
||||
// Allow the case when the channel is full.
|
||||
select {
|
||||
case ch <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
})
|
||||
u.window.SetSize(newW, newH)
|
||||
// Just after SetSize, GetSize is not reliable especially on Linux/UNIX.
|
||||
|
Loading…
Reference in New Issue
Block a user