-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add documentation which explains that debugPrint also logs in release mode
#141595
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
|
This is a heck of a trap door and I think we should deprecate it or patch it so it only prints in debug or profile mode |
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 suspect that with this code the callsites are not actually tree shaken out and the strings (plus all the machinery to generate those, which could be huge if e.g. runtimeType is used) remains in the release binary.
The better advice to give here is that calls to debugPrint should only happen from a debug context (e.g. from within a if (kDebugMode) { } block or within an assert). In general, that is the convention in the framework: methods starting with debug* should only be invoked from a debug context. debugPrint is no exception there.
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 suspect that with this code the callsites are not actually tree shaken out and the strings
Interesting, I wasn't aware of that
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.
Does the avoid_print lint special case this rule? (as-in it should also lint on debugPrint if not used in this way)
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 don't think so. The lint rule just checks for print(...)
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.
In general, that is the convention in the framework: methods starting with
debug*should only be invoked from a debug context.debugPrintis no exception there.
@goderbauer I somewhat disagree, different from the other debug*, they "do-nothing" in release mode, so we should either rename or make sure to make it do nothing by default in release
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.
nit: "Avoid starting a sentence with a lowercase letter.", https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-correct-grammar
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.
nit: missing space:
| /// if(kReleaseMode) { | |
| /// if (kReleaseMode) { |
goderbauer
left a comment
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.
LGTM
gspencergoog
left a comment
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.
…in release mode (flutter/flutter#141595)
…in release mode (flutter/flutter#141595)
…in release mode (flutter/flutter#141595)
…in release mode (flutter/flutter#141595)
flutter/flutter@3ee8ff2...5b673c2 2024-01-23 [email protected] Roll Flutter Engine from fd0335a910b8 to b229878c57f5 (1 revision) (flutter/flutter#142051) 2024-01-23 [email protected] Remove unused clipBehavior from OverflowBar (flutter/flutter#141976) 2024-01-23 [email protected] Roll Packages from e4cbf23 to 841fe90 (7 revisions) (flutter/flutter#142047) 2024-01-23 [email protected] Roll Flutter Engine from d2855da628da to fd0335a910b8 (1 revision) (flutter/flutter#142046) 2024-01-23 [email protected] Add Share button to the SelectableRegion toolbar on Android (flutter/flutter#141447) 2024-01-23 [email protected] Relax the warning of unavailable tokens in `gen_defaults` when a default value is provided (flutter/flutter#140872) 2024-01-23 [email protected] Roll Flutter Engine from 37f68f6fc7fc to d2855da628da (1 revision) (flutter/flutter#142033) 2024-01-23 [email protected] Roll Flutter Engine from 9e582c9032e5 to 37f68f6fc7fc (1 revision) (flutter/flutter#142027) 2024-01-23 [email protected] Roll Flutter Engine from df6b15d35703 to 9e582c9032e5 (1 revision) (flutter/flutter#142026) 2024-01-23 [email protected] Roll Flutter Engine from d3dbd4225e08 to df6b15d35703 (6 revisions) (flutter/flutter#142023) 2024-01-23 [email protected] Add a comment about how to test flutter_goldens (flutter/flutter#141902) 2024-01-23 [email protected] Enable contextMenuBuilder in the absence of selectionControls (flutter/flutter#141810) 2024-01-23 [email protected] Roll Flutter Engine from b069d7f8f1fd to d3dbd4225e08 (3 revisions) (flutter/flutter#142005) 2024-01-23 98614782+auto-submit[bot]@users.noreply.github.com Reverts "hello_world app: migrate to Gradle Kotlin DSL" (flutter/flutter#142018) 2024-01-22 [email protected] Floating cursor docs (flutter/flutter#133002) 2024-01-22 [email protected] refactor: Rename filterPluginsByPlatform, cleanup Platform Strings (flutter/flutter#141780) 2024-01-22 [email protected] hello_world app: migrate to Gradle Kotlin DSL (flutter/flutter#141541) 2024-01-22 [email protected] Roll Flutter Engine from b2762f410840 to b069d7f8f1fd (4 revisions) (flutter/flutter#141993) 2024-01-22 [email protected] Remove duplicate code as suggested by natebosch. (flutter/flutter#141988) 2024-01-22 [email protected] Revert "Remove hack from PageView." (flutter/flutter#141977) 2024-01-22 [email protected] Roll Flutter Engine from d653559ae183 to b2762f410840 (3 revisions) (flutter/flutter#141978) 2024-01-22 [email protected] Do not hang on test failures of tests within `flutter_tools` (flutter/flutter#141821) 2024-01-22 [email protected] Remove unneeded expectation in test (flutter/flutter#141822) 2024-01-22 [email protected] Roll Flutter Engine from 1efe8ba6bc04 to d653559ae183 (3 revisions) (flutter/flutter#141972) 2024-01-22 [email protected] Add documentation which explains that `debugPrint` also logs in release mode (flutter/flutter#141595) 2024-01-22 [email protected] Fix `RangeSlider` throws a null-check error after `clearSemantics` is called (flutter/flutter#141965) 2024-01-22 [email protected] Roll Flutter Engine from c49989292fc1 to 1efe8ba6bc04 (1 revision) (flutter/flutter#141969) 2024-01-22 [email protected] [web] - Fix broken `TextField` in semantics mode when it's a sibling of `Navigator` (flutter/flutter#138446) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

It's confusing that
debugPrintalso prints in release mode, given that a lot (most?) other things prefixed withdebugdon't do anything in release mode. Therefore, this adds some documentation that this is indeed logging in release mode and adds an example how to disable this.If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.