Skip to content

Commit

Permalink
Fix checking against frame_count in Screencopy.match (#119)
Browse files Browse the repository at this point in the history
`self.frame_count` accessed in `match()` could contain a frame number
that is out of sync with the grabbed screenshot. This fix makes sure
that the frame count checked in `match()` is the actual frame count when
`grab_screenshot()` is called.
  • Loading branch information
RAOF authored May 21, 2024
2 parents b24cc8e + 9bbfa26 commit 962fafc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mir-ci/mir_ci/tests/robot/platforms/wayland/Screencopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ async def match(self, template: str, timeout: int = 5) -> List[dict]:
last_checked_frame_count = 0
screenshot = None
while time.time() <= end_time:
screenshot = await asyncio.wait_for(self.grab_screenshot(), timeout)
if last_checked_frame_count != self.frame_count:
last_checked_frame_count = self.frame_count
frame_count, screenshot = await asyncio.wait_for(self.grab_screenshot(), timeout)
if last_checked_frame_count != frame_count:
last_checked_frame_count = frame_count
try:
regions = self._rpa_images.find_template_in_image(
screenshot,
Expand Down Expand Up @@ -82,7 +82,7 @@ async def grab_screenshot(self):
"""
Grabs the current frame tracked by the screencopy tracker.
:return Pillow Image of the frame
:return Tuple (frame count, Pillow Image of the frame)
"""
await self.connect()

Expand All @@ -100,7 +100,7 @@ async def grab_screenshot(self):
b, g, r, a, *_ = image.split()
image = Image.merge("RGBA", (r, g, b, a))

return image
return (self.frame_count, image)

async def connect(self):
"""Connect to the display."""
Expand Down

0 comments on commit 962fafc

Please sign in to comment.