From 928d82c685f12e92e745d9e668c3119c67b7f949 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 18 Apr 2022 02:19:44 +0900 Subject: [PATCH] internal/atlas: potential bug fix: restore images before other image manipulations From the reported stack trace, there could be a potential issue in atlas.BeginFrame: images were manipulated before the images are restored. Restoring images assumes that all images are not stale, but manipulating images like putOnAtlas might cause other images stale in ReplacePixels. Though we failed to reproduce the case, this fix should make sense. Updates #2075 --- internal/atlas/image.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/atlas/image.go b/internal/atlas/image.go index 2d23272de..2ff87f7de 100644 --- a/internal/atlas/image.go +++ b/internal/atlas/image.go @@ -835,12 +835,17 @@ func BeginFrame(graphicsDriver graphicsdriver.Graphics) error { return err } + // Restore images first before other image manipulations (#2075). + if err := restorable.RestoreIfNeeded(graphicsDriver); err != nil { + return err + } + resolveDeferred() if err := putImagesOnAtlas(graphicsDriver); err != nil { return err } - return restorable.RestoreIfNeeded(graphicsDriver) + return nil } func DumpImages(graphicsDriver graphicsdriver.Graphics, dir string) error {