From 33fd7c935a30fbc867be676a094e459643091322 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 17 Oct 2020 06:08:13 +0900 Subject: [PATCH] uidriver/glfw: Avoid (*thread).Call when possible at (*UserInterface).loop Updates #1367 --- internal/uidriver/glfw/ui.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index 5671edd36..00c13900c 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -874,10 +874,16 @@ func (u *UserInterface) loop() error { if err := u.context.Update(); err != nil { return err } - _ = u.t.Call(func() error { - u.swapBuffers() - return nil - }) + + // swapBuffers also checks IsGL, so this condition is redundant. + // However, (*thread).Call is not good for performance due to channels. + // Let's avoid this whenever possible (#1367). + if u.Graphics().IsGL() { + _ = u.t.Call(func() error { + u.swapBuffers() + return nil + }) + } if unfocused { t2 = time.Now()