Skip to content

Update widget location tracking to use the new generalized api - #189725

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
schultek:refactor/widget-location-tracking
Jul 29, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
schultek:refactor/widget-location-tracking

Conversation

@schultek

Copy link
Copy Markdown
Contributor

This refactors Flutters widget tracking setup to use the new generalized CreationLocation API introduced in dart-lang/sdk@9e8fdef

CC @dcharkes

Pre-launch Checklist

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

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@schultek
schultek requested a review from elliette July 20, 2026 14:21
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 20, 2026
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. framework flutter/packages/flutter repository. See also f: labels. labels Jul 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request migrates widget creation tracking from the custom internal _Location and _HasCreationLocation implementations to the standard developer.CreationLocation API. It updates WidgetInspectorService to use developer.CreationLocation.of() and replaces the --track-widget-creation compiler flag with --track-creation-locations across the Flutter tools and associated tests. There are no review comments to address, and I have no additional feedback to provide.

@dcharkes

Copy link
Copy Markdown
Contributor

https://flutter-dashboard.appspot.com/#/presubmit?repo=flutter&pr=189725&sha=3528464e42a786cb9afead6dac8598f981aaa1b6&job=Linux%20tool_tests_general

https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8675749755251589137/+/u/run_test.dart_for_tool_tests_shard_and_subshard_general/stdout

From the looks if it, we just need to update a bunch of test expectations:

00:02 +167 -1: test/general.shard/compile_incremental_test.dart: incremental compile single dart compile abnormally terminates [E]
  Expected: throws <Instance of 'ToolExit'>
    Actual: <Instance of 'Future<CompilerOutput?>'>
     Which: threw TestFailure:<Expected: [
                              'Artifact.engineDartAotRuntime',
                              'Artifact.frontendServerSnapshotForEngineDartSdk',
                              '--sdk-root',
                              'sdkroot/',
                              '--incremental',
                              '--target=flutter',
                              '--experimental-emit-debug-metadata',
                              '--output-dill',
                              '/build/',
                              '--packages',
                              '.dart_tool/package_config.json',
                              '-Ddart.vm.profile=false',
                              '-Ddart.vm.product=false',
                              '--enable-asserts',
                              '--track-widget-creation',
                              '--initialize-from-dill',
                              'build/98469b79d3a7ca103e61af5819c93b8c.cache.dill.track.dill',
                              '--verbosity=error'
                            ]
                    Actual: [
                              'Artifact.engineDartAotRuntime',
                              'Artifact.frontendServerSnapshotForEngineDartSdk',
                              '--sdk-root',
                              'sdkroot/',
                              '--incremental',
                              '--target=flutter',
                              '--experimental-emit-debug-metadata',
                              '--output-dill',
                              '/build/',
                              '--packages',
                              '.dart_tool/package_config.json',
                              '-Ddart.vm.profile=false',
                              '-Ddart.vm.product=false',
                              '--enable-asserts',
                              '--track-creation-locations',
                              '--initialize-from-dill',
                              'build/98469b79d3a7ca103e61af5819c93b8c.cache.dill.track.dill',
                              '--verbosity=error'
                            ]
                     Which: at location [14] is '--track-creation-locations' instead of '--track-widget-creation'
                  >

dcharkes
dcharkes previously approved these changes Jul 21, 2026

@dcharkes dcharkes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @schultek 🙏 LGTM

for (final Object dartDefine in dartDefines) '-D$dartDefine',
...buildModeOptions(buildMode, dartDefines),
if (trackWidgetCreation) '--track-widget-creation',
if (trackWidgetCreation) '--track-creation-locations',

@elliette elliette Jul 21, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This flag (and --no-track-widget-creation) are used in tests, and should be migrated as well. For example:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I only changed the flags passed directly to the compiler invocation. The --track-widget-creation flag of the flutter tool stays as is so there aren't any user-visible changes to the cli flags.

/// * [StatelessWidget], for widgets that always build the same way given a
/// particular configuration and ambient state.
@immutable
@pragma('track-creation-locations')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To confirm, I assume this requires the --track-widget-location or --track-creation-locations flags and therefore will be a no-op in release mode? This seems safe to me. However, since this is a change to Widget I think a lead should review. FYI @Piinks @justinmc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes this has no effect in release mode.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed about release mode, and typically I might be concerned about performance in dev mode, but is this just replacing what used to be hardcoded in the Dart SDK (code)?

    // Legacy Case: Check for widget class.
    if (_isSubclassOfWidget(clazz)) {

In which case it should have no real performance cost at all, even in dev mode. @dcharkes can you confirm?

@schultek
schultek requested review from dcharkes and elliette July 22, 2026 07:30

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM if I can get @dcharkes or someone from the Dart team to confirm that we don't have to worry about dev mode performance loss.

/// * [StatelessWidget], for widgets that always build the same way given a
/// particular configuration and ambient state.
@immutable
@pragma('track-creation-locations')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed about release mode, and typically I might be concerned about performance in dev mode, but is this just replacing what used to be hardcoded in the Dart SDK (code)?

    // Legacy Case: Check for widget class.
    if (_isSubclassOfWidget(clazz)) {

In which case it should have no real performance cost at all, even in dev mode. @dcharkes can you confirm?

@dcharkes

Copy link
Copy Markdown
Contributor

LGTM if I can get @dcharkes or someone from the Dart team to confirm that we don't have to worry about dev mode performance loss.

Agreed about release mode, and typically I might be concerned about performance in dev mode, but is this just replacing what used to be hardcoded in the Dart SDK (code)?

    // Legacy Case: Check for widget class.
    if (_isSubclassOfWidget(clazz)) {

In which case it should have no real performance cost at all, even in dev mode. @dcharkes can you confirm?

Yes, this is just replacing the hardcoded thing in the SDK!

@justinmc
justinmc force-pushed the refactor/widget-location-tracking branch from a058830 to fbf8c96 Compare July 28, 2026 22:43

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 . Thanks @dcharkes for confirming. The failure was due to the PR being out of date, so I've rebased it.

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 28, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 29, 2026
Merged via the queue into flutter:master with commit e47832b Jul 29, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 29, 2026
@schultek
schultek deleted the refactor/widget-location-tracking branch July 29, 2026 07:26
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Aug 8, 2026
…12393)

Manual roll requested by [email protected]

flutter/flutter@2a230d1...2757a77

2026-07-29 [email protected] Roll Skia from 3ae9e364d30b to 0f35bba4945c (2 revisions) (flutter/flutter#190215)
2026-07-29 [email protected] [web] Fix deferred loading with wasm (flutter/flutter#190140)
2026-07-29 [email protected] Roll Dart SDK from 1bbaacba6a5a to 43f7de5f4977 (1 revision) (flutter/flutter#190211)
2026-07-29 [email protected] Roll Skia from 119cae396625 to 3ae9e364d30b (6 revisions) (flutter/flutter#190208)
2026-07-29 [email protected] [Win32] Ignore mouse move events without capture when dragging (flutter/flutter#190029)
2026-07-29 [email protected] Roll Dart SDK from 49c637261348 to 1bbaacba6a5a (7 revisions) (flutter/flutter#190196)
2026-07-29 [email protected] Roll Skia from 30ad01017a46 to 119cae396625 (2 revisions) (flutter/flutter#190183)
2026-07-29 [email protected] Fix NestedScrollView example crash when switching tabs on desktop (flutter/flutter#186993)
2026-07-29 [email protected] Roll Fuchsia Linux SDK from OZkZC_2CZ_G5rbMIS... to J8rVTlBnjnUpuHYk3... (flutter/flutter#190174)
2026-07-29 [email protected] Update widget location tracking to use the new generalized api (flutter/flutter#189725)
2026-07-29 [email protected] Avoid unnecessary work in `BoxDecoration` and `RenderPhysicalModel` (flutter/flutter#187891)
2026-07-29 [email protected] Fix web context-menu client lifecycle in SelectableRegion (flutter/flutter#189587)
2026-07-29 [email protected] Roll Skia from 70733f74d415 to 30ad01017a46 (2 revisions) (flutter/flutter#190173)
2026-07-29 [email protected] Manual roll of Dart from 28e63ac22d8d to 49c637261348 (flutter/flutter#190158)

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] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants