-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[performance] Trace direct calls to inflateWidget #98277
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
| Element inflateWidget(Widget newWidget, Object? newSlot) { | ||
| assert(newWidget != null); | ||
|
|
||
| if (!kReleaseMode && debugProfileBuildsEnabled) { |
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.
are profiles even useful with this much debug code running?
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 profile mode, this will only add the Widget's name to the timeline if debugProfileBuildsEnabled is manually enabled. (Only in debug mode do you also get extra "timeline arguments" from the diagnostics mode...)
It's sort of the point of the debugProfileBuildsEnabled option to get you that extra information in profile mode at the expense of skewing with performance numbers, which is documented on the flag.
jonahwilliams
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
|
Note that this PR increased the stack size per nesting level: |
Some
Elements in the framework and in the outside world callinflateWidgetdirectly instead of going throughupdateChildto inflate widgets. Widgets inflated that way did not show up in tracing withdebugProfileBuildsEnabledbecause onlyupdateChildwas instrumented with tracing. This PR moves the instrumentation toinflateWidgetto trace all widgets inflations - whether they are triggered viaupdateChildor directly viainflateWidget.The most notable Element in the framework that's going straight to
inflateWidgetisMultiChildRenderObjectElement:flutter/packages/flutter/lib/src/widgets/framework.dart
Line 6451 in 4f975cb
MultiChildRenderObjectElementpowers common widgets likeRow,Column, andStackamong many others - all of which had their direct children omitted from traces. But no more!