Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Move Widget Inspector service extensions from DevTools to Flutter #113861

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

Merged
merged 13 commits into from
Oct 28, 2022

Conversation

kenzieschmoll
Copy link
Member

@kenzieschmoll kenzieschmoll commented Oct 21, 2022

These service extensions have been dynamically registered from DevTools for years now (see inspector_polyfill_script.dart). Originally, when DevTools had to be backwards compatible with older versions of Flutter, this was a way to guarantee these service extensions would be available for any version of Flutter. Since this time, we have changed the DevTools distribution strategy to ship DevTools with the Dart SDK, so we no longer have to be concerned with backwards compatibility issues.

Moving these service extension registrations to the widget_inspector.dart file in Flutter is a tech debt clean up, and also a performance improvement for DevTools IPL. This change will eliminate the need for the DevTools inspector to perform an expensive 'eval' at the initial load of the inspector to register the service extensions (@annagrin). The initial expression compilation that draws the Flutter layout explorer takes ~3sec when connected to a flutter web app built with DDC, which, before this change, delayed the time until the flutter inspector was ready for user action. This change prevents the 3 seconds delay from happening before the inspector loads. However, the delay will still exist for the first load of the layout explorer (the cost is loading the widget_inspector.dart file for evaluation). This is a separate problem that will be tackled in a separate effort.

All the new service extensions added in this PR are copied from https://github.com/flutter/devtools/blob/master/packages/devtools_app/assets/scripts/inspector_polyfill_script.dart with minimal changes for adhering to the flutter/flutter style guide and lints.

This is the required flutter changes for flutter/devtools#4634. DevTools changes are in flutter/devtools#4633.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Oct 21, 2022
@kenzieschmoll kenzieschmoll marked this pull request as ready for review October 25, 2022 18:52
@@ -1127,6 +1123,10 @@ mixin WidgetInspectorService {
return null;
},
);
registerServiceExtension(
Copy link
Member Author

@kenzieschmoll kenzieschmoll Oct 25, 2022

Choose a reason for hiding this comment

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

The service extensions added in this file are copied / moved from https://github.com/flutter/devtools/blob/master/packages/devtools_app/assets/scripts/inspector_polyfill_script.dart with minimal changes for adhering to the flutter/flutter style guide and lints.

@@ -2216,6 +2223,97 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
expect(childJson['chidlren'], isNull);
}, skip: !WidgetInspectorService.instance.isWidgetCreationTracked()); // [intended] Test requires --track-widget-creation flag.

testWidgets('ext.flutter.inspector.getRootWidgetSummaryTreeWithPreviews', (WidgetTester tester) async {
Copy link
Member Author

Choose a reason for hiding this comment

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

The tests added to this file are all new, as we did not have tests for these service extensions in DevTools.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@kenzieschmoll kenzieschmoll added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 28, 2022
@auto-submit auto-submit bot merged commit cdbb1e6 into flutter:master Oct 28, 2022
@kenzieschmoll kenzieschmoll deleted the inspector-extensions branch October 28, 2022 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants