Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restartable timers #3702

Open
wants to merge 5 commits into
base: matejcik/global-layout-only3
Choose a base branch
from

Conversation

matejcik
Copy link
Contributor

@matejcik matejcik commented Apr 10, 2024

fixes "Queue overflow" error in T2B1 click tests which happens if (a) your CPU is fast enough or (b) you improve performance of UI code too much (also supersedes #3363 which could not be merged due to the speed improvement triggering this problem)

Summary of problem

Every button click in some screens will fire off a new timer event. Previously, there was no way to unschedule those timer events, so if you sent events too fast, there would be too many timers and they would overflow the queue

Summary of solution

A same logical timer will now reuse its event if it is already scheduled.
The performance cost amortizes to zero -- you spend work upfront to unschedule the event, but you save work of processing an already scheduled event which will be ignored in the end.
This means that every button click will schedule the same timer over and over again, saving precious queue space.

Quality of life

Timer is now a nicer struct member in that the user doesn't need to manually manage their Option<TimerToken>, and internally handles starting, stopping, and restarting.

Other changes

(removed unrelated changes, a separate PR will follow)

@matejcik matejcik requested a review from prusnak as a code owner April 10, 2024 10:09
@matejcik
Copy link
Contributor Author

TODO: I again forgot to add a changelog (this time for what was #3633 which is an impactful change that could plausibly affect users)

Copy link

github-actions bot commented Apr 10, 2024

legacy UI changes device test(screens) main(screens)

Copy link

github-actions bot commented Apr 10, 2024

core UI changes device test click test persistence test
T2T1 Model T test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T2B1 Safe 3 test(screens) main(screens) test(screens) main(screens) 2724
T3T1 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
All main(screens)

@matejcik matejcik requested review from mmilata and obrusvit and removed request for prusnak April 10, 2024 10:26
@matejcik matejcik self-assigned this Apr 10, 2024
@Hannsek
Copy link
Contributor

Hannsek commented Apr 11, 2024

impactful change that could plausibly affect users

How?

@matejcik
Copy link
Contributor Author

see the changelog:

Improved device responsiveness by removing unnecessary screen refreshes.

if I missed a refresh somewhere, someone will see it as bad screen response

… are gone

this juuust might fix unexplained freezes on hardware
This was necessary for hooking display.refresh() with the old UI toolkit.
With the new one, we explicitly refresh the display after every paint, so
implicit after-step refresh seems no longer necessary.
Copy link
Contributor

@obrusvit obrusvit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔎 Needs review
Development

Successfully merging this pull request may close these issues.

None yet

4 participants