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

defer attach menu creation #2543

Merged
merged 1 commit into from
Jan 23, 2025
Merged

defer attach menu creation #2543

merged 1 commit into from
Jan 23, 2025

Conversation

r10s
Copy link
Member

@r10s r10s commented Jan 22, 2025

this PR creates the attach menu only if needed;
this was also the case in the past, when we were using an alert instead of modern menu.

it is only a little bit faster currently (2~3ms vs <0.5ms on iphone7), however, as this also may be used as a pattern and as slower conditions may be added in the future, maybe still worth going for it.
also to exclude that part from being slow.

#skip-changelog

this PR creates the attach menu only if needed;
this was also the case in the past, when we were using an alert instead of modern menu.

it is only a little bit faster currently (2~3ms vs <0.5ms on iphone7),
however, as this also may be used as a pattern and as slower conditions may be added in the future,
maybe still worth going for it.
also to exclude that part from being slow.
@r10s r10s requested a review from Amzd January 22, 2025 13:00
@Amzd
Copy link
Collaborator

Amzd commented Jan 22, 2025

I don't fully understand the caching that happens. Is it cached until the next time the UIMenu is initialized or longer? Eg if you open the menu then turn off experimental location sharing feature, does it still show the button?

@r10s
Copy link
Member Author

r10s commented Jan 22, 2025

imu and tests, it is cached as long as the parent exist:

  • when you exit and reenter the view controller, you get a new menu (so yes: when the the next time the UIMenu is initialized, this will also UIDeferredMenuElement callback being called again)
  • if you close and reopen the menu without leaving the view controller, the cache is used

to not use the caching at all, there is UIDeferredMenuElement.uncached()

@r10s r10s merged commit 7cf10a3 into main Jan 23, 2025
2 checks passed
@r10s r10s deleted the r10s/defer-clipper-menu-creation branch January 23, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants