From 8b1100888e744f3c6d16687f8f9a0d44ac6b710d Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 23 Apr 2021 03:02:06 +0900 Subject: [PATCH] internal/uidriver/glfw: Bug fix: Always wait for SetFramebuffer In case when the callback is not called, let's use timeout. Updates #1618 --- internal/uidriver/glfw/ui.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index be0c6e0f2079..6c8ad162383d 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -1042,15 +1042,21 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) { ch <- struct{}{} }) u.window.SetSize(newW, newH) - if w, h := u.window.GetSize(); w != oldW || h != oldH { - event: - for { - glfw.PollEvents() - select { - case <-ch: - break event - default: - } + // Just after SetSize, GetSize is not reliable especially on Linux/Windows. + // Let's wait for FramebufferSize callback in any cases. + + // Use the timeout as FramebufferSize event might not be fired (#1618). + t := time.NewTimer(time.Second) + defer t.Stop() + event: + for { + glfw.PollEvents() + select { + case <-ch: + break event + case <-t.C: + break event + default: } } u.window.SetFramebufferSizeCallback(nil)