From b86f1771e4f8b5cb005bb6338a93025595553389 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 29 Nov 2016 01:40:06 +0900 Subject: [PATCH] ui: Add goroutine so that blocking is available everywhere --- internal/ui/ui_js.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 5b61354ab..2f36c8d41 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -96,12 +96,14 @@ func (u *userInterface) loop(g GraphicsContext) error { ch := make(chan error) var f func() f = func() { - if err := u.update(g); err != nil { - ch <- err - close(ch) - return - } - js.Global.Get("window").Call("requestAnimationFrame", f) + go func() { + if err := u.update(g); err != nil { + ch <- err + close(ch) + return + } + js.Global.Get("window").Call("requestAnimationFrame", f) + }() } f() return <-ch