[no changelog]
@ -618,6 +618,11 @@ class TrezorClientDebugLink(TrezorClient):
Callable[[protobuf.MessageType], protobuf.MessageType],
] = {}
def ensure_open(self) -> None:
"""Only open session if there isn't already an open one."""
if self.session_counter == 0:
self.open()
def open(self) -> None:
super().open()
if self.session_counter == 1:
@ -153,6 +153,7 @@ def screen_recording(
client.debug.start_recording(str(screen_path))
yield
finally:
client.ensure_open()
# Wait for response to Initialize, which gives the emulator time to catch up
# and redraw the homescreen. Otherwise there's a race condition between that
# and stopping recording.