Skip to content

Conversation

@liyuqian
Copy link
Contributor

Description

Developers may get confused by setting PaintingBinding.shaderWarmUp in
the wrong place. The added assert and error message help avoid that.

Related Issues

#813

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes tests for all changed/updated/fixed behaviors (See Test Coverage).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

Developers may get confused by setting PaintingBinding.shaderWarmUp in
the wrong place. The added assert and error message help avoid that.
@liyuqian liyuqian requested review from Hixie and mklim March 28, 2019 23:22
@liyuqian
Copy link
Contributor Author

@InMatrix : please let me know if the error message conforms your UX research results :)

Copy link
Contributor

@mklim mklim left a comment

Choose a reason for hiding this comment

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

LGTM

assert(_instance == null,
'PaintingBinding.shaderWarmUp should only be set before the '
'PaintingBinding singleton instance is initialized.\n\n'
'Set it after init would not affect how shaders are warmed up.\n\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit:

Suggested change
'Set it after init would not affect how shaders are warmed up.\n\n'
'Setting it after init does not affect how shaders are warmed up.\n\n'

"Set" here makes it sound like a command so it's confusing as is, because I think this sentence is really talking about the times when this is set after init and not telling the reader to set it after init. "Setting" changes it to a gerund and the subject of this sentence, which makes more sense. Then the "would" to "does" here change follows to match that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/// * [ShaderWarmUp], the interface of how this warm up works.
static ShaderWarmUp shaderWarmUp = const DefaultShaderWarmUp();
static ShaderWarmUp get shaderWarmUp => _shaderWarmUp;
static void set shaderWarmUp(ShaderWarmUp value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This is failing the analyzer. "Avoid return types on setters"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you very much for the suggestion! Done.

@InMatrix
Copy link

@liyuqian Thanks for pinging me. Being unfamiliar with the code, I can't really tell if the message is sufficient. But it's certainly a step towards the right direction.

@liyuqian liyuqian merged commit ffbb335 into flutter:master Mar 29, 2019
liyuqian added a commit to liyuqian/flutter that referenced this pull request Apr 3, 2019
This reverts commit ffbb335.

Reason for revert: flutter driver tests may have bugs in getting
first frame. Revert this until we figure out what happened.
liyuqian added a commit that referenced this pull request Apr 3, 2019
…0463)

This reverts commit ffbb335.

Reason for revert: flutter driver tests may have bugs in getting
first frame. Revert this until we figure out what happened.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants