From 2e605f2dcb716192ce9effe9eb3c6889101b6857 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 30 Oct 2019 00:49:48 +0100 Subject: [PATCH] app: ensure the previous frame is complete before accepting another It matters for end-to-end tests that rely on the window contents. Before this change, tests had to wait for 2 extra frames. This change ensures that the first completed FrameEvent.Frame call guarantees the previous frame is complete. Signed-off-by: Elias Naur --- app/window.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/window.go b/app/window.go index 201680ff..509b3d19 100644 --- a/app/window.go +++ b/app/window.go @@ -261,13 +261,6 @@ func (w *Window) run(opts *window.Options) { w.hasNextFrame = false e2.Frame = w.update w.out <- e2.FrameEvent - var frame *op.Ops - // Wait for either a frame or the ack event, - // which meant that the client didn't draw. - select { - case frame = <-w.frames: - case w.out <- ackEvent: - } if w.gpu != nil { if e2.Sync { w.gpu.Refresh() @@ -290,6 +283,13 @@ func (w *Window) run(opts *window.Options) { return } } + var frame *op.Ops + // Wait for either a frame or the ack event, + // which meant that the client didn't draw. + select { + case frame = <-w.frames: + case w.out <- ackEvent: + } w.draw(e2.Size, frame) if e2.Sync { if err := w.gpu.Flush(); err != nil {