trezor-firmware
trezor-firmware copied to clipboard
core UI: single global layout
Fixes #2299, also should fix a race condition in tests that has caused problems in the past, also reduces the need to pass Context to layout functions.
I'm not very happy about BufferLock-related changes in 6000b74 as they add a level of indent to already complex code. Changing this part was needed because test_show_multisig_xpubs causes both WebUSB and DebugLink to process a protobuf message at the same time, so we just allocate new buffer instead of aborting. Let me know if you have better idea how to solve this.
BufferLock-related changes
how about keeping most of the original, but make the BufferLock async, as in:
async def __aenter__(self):
while self.in_use:
yield
(and then async with buffer_lock)
async def __aenter__(self): while self.in_use: yield
I've tried this and it resulted in a deadlock - firmware writing to WebUSB buffer, trezorlib reading from DebugLink interface (or vice-versa, don't remember).
I've tried this and it resulted in a deadlock
right so what if we just put back debuglink's own buffer? it doesn't need to be 8 kB, by a rough calculation 512 bytes might be enough, or 1 kB to be on the safe side. we should be able to afford that now.
so what if we just put back debuglink's own buffer?
Done in 3a976973965971dbf650ad7bbbff6199ee52169c
Rebased and fixed conflicts.
hackathon results are in hackathon-global-layout branch
further idea: debuglink should send decisions not via the global confirm_chan, but directly to the running layout object -- presumably what is now self._cancel_chan can be just self.chan or something, and both the do_cancel() method and debuglink can insert results into it directly.
this also allows us to get rid of confirm_chan integration in a lot of places (but that becomes less relevant when we switch over to RustLayout)
Pushed:
- 585e525 cleaned-up hackathon changes
- 8397f7e ugly hack that prevents layout desynchronization in
test_show_multisig_xpubs
Unfortunately this breaks click tests because layout notifications now seem to have problem working across session restarts. @matejcik can you please take a look at this? I'm out of ideas what to try. It's reproducible with PYTEST_TIMEOUT=5 pytest -x ../tests/click_tests -k 1of1.
In mmilata/global-layout-notify-after-br I tried sending the layout notification after ButtonRequest but before the layout is actually painted. Sounds wrong but works surprisingly well except that it breaks test_signtx_data_pagination[input_flow_go_back].
superseded by https://github.com/trezor/trezor-firmware/pull/3686