uidriver/mobile: Bug fix: Freeze on Pixel 4

An Ebiten application often freezes on Pixel 4. Apparently adding
loggings or runtime.Gosched hides the issue, though this doesn't fix
the root cause. The root cause might be in gomobile itself, but it
seeems really hard to make a minimum case.

As a tentative fix, add runtime.Gosched to avoid freezing.

Fixes #1322
This commit is contained in:
Hajime Hoshi 2020-08-29 19:26:05 +09:00
parent 179d32cfbf
commit deb3d4a0c3

View File

@ -19,6 +19,7 @@ package mobile
import (
"context"
"fmt"
"runtime"
"runtime/debug"
"sync"
"sync/atomic"
@ -107,6 +108,11 @@ func (u *UserInterface) Update() error {
select {
case <-workAvailable:
u.glWorker.DoWork()
// This is a dirty hack to avoid freezing on Pixel 4 (#1322).
// Apprently there is an issue in the usage of Worker in gomobile or gomobile itself.
// At least, freezing doesn't happen with this Gosched.
runtime.Gosched()
case <-ctx.Done():
break loop
}