Skip to content

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Oct 19, 2022

This drops the ui thread usage 27.5% in local testing for a screen that is just showing a cursor.

issue: #59327

before:
Screen Shot 2022-10-19 at 10 47 11 AM

after:
Screen Shot 2022-10-19 at 11 54 30 AM

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Oct 19, 2022
@gaaclarke gaaclarke marked this pull request as ready for review October 19, 2022 20:38
@flutter-dashboard
Copy link

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.

@gaaclarke gaaclarke changed the title Dropped the update frequency from 60fps to 4fps for the text input. Dropped the update frequency from 60hz to 4hz for the text input. Oct 19, 2022
@gaaclarke gaaclarke changed the title Dropped the update frequency from 60hz to 4hz for the text input. Dropped the update frequency from 60hz to 4hz for the text input composing rect Oct 19, 2022
@LongCatIsLooong
Copy link
Contributor

Thanks for attaching the profile results, is the target a macOS app or iOS app?

@gaaclarke
Copy link
Member Author

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());
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong Oct 19, 2022

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.

Copy link
Member Author

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.

Copy link
Member Author

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?

@gaaclarke

This comment was marked as outdated.

@gaaclarke
Copy link
Member Author

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.

@gaaclarke gaaclarke marked this pull request as draft October 19, 2022 21:53
@flutter-dashboard
Copy link

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 package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@gaaclarke
Copy link
Member Author

Dropping this since a better alternative is reacting to changes directly instead of sampling a certain frequency.

@gaaclarke gaaclarke closed this Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants