app: don't deadlock if Window.validateAndProcess fails

Fixes: https://todo.sr.ht/~eliasnaur/gio/417
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-05-27 11:31:13 +02:00
parent 28acb79b82
commit 2a0a196d1a
+13 -5
View File
@@ -178,7 +178,16 @@ func (w *Window) update(frame *op.Ops) {
<-w.frameAck <-w.frameAck
} }
func (w *Window) validateAndProcess(d driver, size image.Point, sync bool, frame *op.Ops, signal chan<- struct{}) error { func (w *Window) validateAndProcess(d driver, size image.Point, sync bool, frame *op.Ops, sigChan chan<- struct{}) error {
signal := func() {
if sigChan != nil {
// We're done with frame, let the client continue.
sigChan <- struct{}{}
// Signal at most once.
sigChan = nil
}
}
defer signal()
for { for {
if w.gpu == nil && !w.nocontext { if w.gpu == nil && !w.nocontext {
var err error var err error
@@ -235,10 +244,9 @@ func (w *Window) validateAndProcess(d driver, size image.Point, sync bool, frame
} }
} }
w.queue.q.Frame(frame) w.queue.q.Frame(frame)
// We're done with frame, let the client continue. // Let the client continue as soon as possible, in particular before
if signal != nil { // a potentially blocking Present.
signal <- struct{}{} signal()
}
var err error var err error
if w.gpu != nil { if w.gpu != nil {
err = w.ctx.Present() err = w.ctx.Present()