trezor-firmware icon indicating copy to clipboard operation
trezor-firmware copied to clipboard

core UI: single global layout

Open mmilata opened this issue 3 years ago • 7 comments

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.

mmilata avatar Jun 10 '22 14:06 mmilata

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)

matejcik avatar Jun 27 '22 10:06 matejcik

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).

mmilata avatar Jun 28 '22 11:06 mmilata

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.

matejcik avatar Jun 28 '22 12:06 matejcik

so what if we just put back debuglink's own buffer?

Done in 3a976973965971dbf650ad7bbbff6199ee52169c

mmilata avatar Jun 30 '22 11:06 mmilata

Rebased and fixed conflicts.

mmilata avatar Jul 20 '22 09:07 mmilata

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)

matejcik avatar Jul 20 '22 15:07 matejcik

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].

mmilata avatar Jul 27 '22 17:07 mmilata

superseded by https://github.com/trezor/trezor-firmware/pull/3686

matejcik avatar Apr 08 '24 09:04 matejcik