mobile: Bug fix: error must be received without waiting for renderCh

Even when error happens, the error was not received when renderCh
received. This was the cause of freezing when error happens.
This commit is contained in:
Hajime Hoshi 2019-01-28 12:32:46 +09:00
parent 5ccd240a35
commit ba47a19b17
3 changed files with 6 additions and 6 deletions

View File

@ -73,7 +73,7 @@ type contextImpl struct {
worker mgl.Worker
}
func (c *context) doWork(chError <-chan error, chDone <-chan struct{}) error {
func (c *context) doWork(chDone <-chan struct{}) error {
if c.worker == nil {
panic("not reached")
}
@ -82,8 +82,6 @@ func (c *context) doWork(chError <-chan error, chDone <-chan struct{}) error {
loop:
for {
select {
case err := <-chError:
return err
case <-workAvailable:
c.worker.DoWork()
case <-chDone:

View File

@ -20,8 +20,8 @@ import (
"golang.org/x/mobile/gl"
)
func (d *Driver) DoWork(chError <-chan error, chDone <-chan struct{}) error {
return d.context.doWork(chError, chDone)
func (d *Driver) DoWork(chDone <-chan struct{}) error {
return d.context.doWork(chDone)
}
func (d *Driver) Init() {

View File

@ -52,8 +52,10 @@ func Render(chError <-chan error) error {
}
// TODO: Check this is called on the rendering thread
select {
case err := <-chError:
return err
case renderCh <- struct{}{}:
return opengl.Get().DoWork(chError, renderChEnd)
return opengl.Get().DoWork(renderChEnd)
case <-time.After(500 * time.Millisecond):
// This function must not be blocked. We need to break for timeout.
return nil