mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
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:
parent
5ccd240a35
commit
ba47a19b17
@ -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:
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user