diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e7c8ac7..c0ad5b34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.5] - 2024-04-11 + +### Fixed + +- Fix race condition on screenshot generation + ## [0.8.4] - 2024-04-10 ### Fixed diff --git a/speculos/mcu/display.py b/speculos/mcu/display.py index 80c0ae54..be77680f 100644 --- a/speculos/mcu/display.py +++ b/speculos/mcu/display.py @@ -82,6 +82,7 @@ def __init__(self, model: str): self.screenshot_pixels: PixelColorMapping = {} self.default_color = 0 self.draw_default_color = False + self.reset_screeshot_pixels = False self._public_screenshot_value = b'' self.current_data = b'' self.recreate_public_screenshot = True @@ -112,7 +113,7 @@ def draw_rect(self, x0: int, y0: int, width: int, height: int, color: int) -> Li self.default_color = color self.draw_default_color = True self.pixels = {} - self.screenshot_pixels = {} + self.reset_screeshot_pixels = True return [TextEvent("", 0, 0, 0, 0, True)] for x in range(x0, x0 + width): @@ -129,6 +130,7 @@ def _get_image(self) -> bytes: return bytes(data) def _get_screenshot_iobytes_value(self) -> bytes: + print("_get_screenshot_iobytes_value") # Get the pixels object once, as it may be replaced during the loop. data = self._get_image() @@ -141,6 +143,9 @@ def take_screenshot(self) -> Tuple[Tuple[int, int], bytes]: return self.current_screen_size, self._get_image() def update_screenshot(self) -> None: + if self.reset_screeshot_pixels: + self.screenshot_pixels = {} + self.reset_screeshot_pixels = False self.screenshot_pixels.update(self.pixels) def update_public_screenshot(self) -> None: