From f332fa61c16fa03a17815db12251df4076e85881 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 31 Aug 2020 01:01:36 +0900 Subject: [PATCH] uidriver/mobile: Refactoring --- internal/uidriver/mobile/ui.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/uidriver/mobile/ui.go b/internal/uidriver/mobile/ui.go index 49009454b..1697afce3 100644 --- a/internal/uidriver/mobile/ui.go +++ b/internal/uidriver/mobile/ui.go @@ -17,7 +17,6 @@ package mobile import ( - "context" "fmt" "runtime" "runtime/debug" @@ -89,14 +88,13 @@ func (u *UserInterface) Update() error { panic("mobile: glWorker must be initialized but not") } - ctx, cancel := context.WithCancel(context.Background()) + done := make(chan struct{}) go func() { <-renderEndCh - cancel() + close(done) }() workAvailable := u.glWorker.WorkAvailable() - loop: for { select { case <-workAvailable: @@ -106,11 +104,10 @@ func (u *UserInterface) Update() error { // 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 + case <-done: + return nil } } - return nil } go func() {