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

Minimal implementation of FlutterError.toString for release mode #54291

Merged
merged 1 commit into from
Apr 9, 2020

Conversation

jason-simmons
Copy link
Member

Fixes #54038

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Apr 8, 2020
@fluttergithubbot
Copy link
Contributor

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.

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

@@ -890,6 +890,10 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti

@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
if (kReleaseMode) {
final Iterable<_ErrorDiagnostic> errors = diagnostics.whereType<_ErrorDiagnostic>();
Copy link
Contributor

Choose a reason for hiding this comment

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

How much does this increase binary size? That was the primary driver of this change

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we want to completely avoid retaining the diagnostics related classes

Copy link
Member Author

Choose a reason for hiding this comment

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

This will slightly reduce the binary size. For the sample app in #54038 the total size of the segments in libapp.so is:

  • 3611038 with this patch
  • 3613222 without

The diagnostics classes are present in the release build, but their toString methods return an empty string. FlutterError.toString was passing the diagnostics nodes to the TextTreeRenderer, which just yields a series of empty strings. With this patch FlutterError.toString will return the value of the ErrorSummary, and the compiler can eliminate the TextTreeRenderer invocation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh ok nice

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM

@fluttergithubbot fluttergithubbot merged commit 173c93d into flutter:master Apr 9, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FlutterError.toString empty in release mode
4 participants