ui: Frame skip on JS

This commit is contained in:
Hajime Hoshi 2015-02-21 22:19:26 +09:00
parent 5e5eea59ce
commit 246ac055bf

View File

@ -78,11 +78,21 @@ func shown() bool {
func vsync() { func vsync() {
ch := make(chan struct{}) ch := make(chan struct{})
// As the performance is generally not good with GopehrJS, consume n 'requestAnimationFrame's
// each time.
n := 2
var l func()
l = func() {
if 0 < n {
n--
// TODO: In iOS8, this is called at every 1/30[sec] frame. // TODO: In iOS8, this is called at every 1/30[sec] frame.
// Can we use DOMHighResTimeStamp? // Can we use DOMHighResTimeStamp?
js.Global.Get("window").Call("requestAnimationFrame", func() { js.Global.Get("window").Call("requestAnimationFrame", l)
return
}
close(ch) close(ch)
}) }
l()
<-ch <-ch
} }