You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
This does not usually happen on emulator because sending data on emulator is very fast.
However, if sending data is not fast, the following race condition may occur:
host asks for DebugLinkGetState, where the response needs multiple USB packets (this is most screens actually, the layout json is long)
firmware starts streaming the DebugLinkState response, pausing on every write until the USB link is ready
during the pause, wirelink workflow handler is resumed
wirelink workflow handler exits and starts sending a Success message, which fits in just one packet
Success packet write loop ends (the packet is in an outgoing buffer or w/e)
wirelink calls loop.clear() to clean out the memory and "reboot" the micropython env
this clears out the pending debuglink write task
host gets stuck waiting for remaining packets of the DebugLinkState response which will never be sent
A hot-fix on host side is to implement a timeout for the DebugLinkState wait, and ignore failures here.
Proper fix on firmware side involves something like registering "units of work" with the workflow manager (and/or loop scheduler), and run loop.clear() not after a workflow but instead "when no units of work are pending".
(This approach would also solve the problems that THP is facing with not knowing very well when it's safe to call loop.clear())
The text was updated successfully, but these errors were encountered:
Describe the bug
This does not usually happen on emulator because sending data on emulator is very fast.
However, if sending data is not fast, the following race condition may occur:
DebugLinkGetState
, where the response needs multiple USB packets (this is most screens actually, the layout json is long)DebugLinkState
response, pausing on every write until the USB link is readyloop.clear()
to clean out the memory and "reboot" the micropython envDebugLinkState
response which will never be sentA hot-fix on host side is to implement a timeout for the DebugLinkState wait, and ignore failures here.
Proper fix on firmware side involves something like registering "units of work" with the workflow manager (and/or loop scheduler), and run
loop.clear()
not after a workflow but instead "when no units of work are pending".(This approach would also solve the problems that THP is facing with not knowing very well when it's safe to call
loop.clear()
)The text was updated successfully, but these errors were encountered: