diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 833ac7a4a..12f778d2f 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -320,10 +320,13 @@ func IsRunnableInBackground() bool { func SetVsyncEnabled(enabled bool) { u := currentUI if !u.isRunning() { - _ = u.runOnMainThread(func() error { - u.vsync = enabled - return nil - }) + // In general, m is used for locking init* values. + // m is not used for updating vsync in setScreenSize so far, but + // it should be OK since any goroutines can't reach here when + // the game already starts and setScreenSize can be called. + u.m.Lock() + u.vsync = enabled + u.m.Unlock() return } _ = u.runOnMainThread(func() error {