-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Dropped the update frequency from 60hz to 4hz for the text input composing rect #113722
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
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Thanks for attaching the profile results, is the target a macOS app or iOS app? |
That's on iOS. |
| assert(composingRect != null); | ||
| _textInputConnection!.setComposingRect(composingRect); | ||
| SchedulerBinding.instance.addPostFrameCallback((Duration _) => _updateComposingRectIfNeeded()); | ||
| Future<void>.delayed(const Duration(milliseconds: 250), () => _updateComposingRectIfNeeded()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could lead to crash? The text in the input field can be changed between frames, or after the transient callback phase, and as a result TextPainter will probably crash when _updateComposingRectIfNeeded queries invalidated text layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can switch it around to still be tied to addPostFrameCallback as long as you think that dropping the frequency to 4hz is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched it so that the delay adds a post frame callback. That addresses your concern, right?
This comment was marked as outdated.
This comment was marked as outdated.
…ting functions too (didn't make a big change in cpu usage like the original one)
|
This naive approach will take a bit more work to make work and it sounds like there might be a better alternative. Dropping this back to a draft for now. |
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Dropping this since a better alternative is reacting to changes directly instead of sampling a certain frequency. |
This drops the ui thread usage 27.5% in local testing for a screen that is just showing a cursor.
issue: #59327
before:

after:

Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.