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

Widget Inspector shows too many widgets #6841

Closed
johnpryan opened this issue Nov 28, 2023 · 10 comments · Fixed by #6857
Closed

Widget Inspector shows too many widgets #6841

johnpryan opened this issue Nov 28, 2023 · 10 comments · Fixed by #6857
Labels
bug Something isn't working inspector page

Comments

@johnpryan
Copy link
Contributor

When I open the Widget Inspector for the counter app, I get a simplified version of the widget tree, but when I open it for DartPad (pkgs/sketch_pad), I see a very complex widget tree, with widgets like View and MediaQuery, that aren't part of my application code.

Counter app:

Screenshot 2023-11-28 at 10 01 05 AM

DartPad:

Screenshot 2023-11-28 at 10 05 04 AM

@johnpryan johnpryan added inspector page bug Something isn't working labels Nov 28, 2023
@kenzieschmoll
Copy link
Member

Can you check your Package Directories in the Inspector settings and post a screenshot of what is there?

@johnpryan
Copy link
Contributor Author

Screenshot 2023-11-29 at 12 17 04 PM

@elliette
Copy link
Member

@jacob314 and I were just discussing something similar where an internal customer's widget tree is comprised of primarily Provider widgets, making it quite user-unfriendly.

@kenzieschmoll
Copy link
Member

Delete the flutter SDK from the list of package directories. I'm not sure how this was added to the list. @CoderDake could there be a bug in our package directory detection logic?

@kenzieschmoll
Copy link
Member

@jacob314 and I were just discussing something similar where an internal customer's widget tree is comprised of primarily Provider widgets, making it quite user-unfriendly.

Were these Provider widgets ones that they defined in their app? Or were they widgets from the internals of package:provider?

@johnpryan
Copy link
Contributor Author

Delete the flutter SDK from the list of package directories. I'm not sure how this was added to the list. @CoderDake could there be a bug in our package directory detection logic?

I'm not sure either, but that fixed it for me.

@jacob314 and I were just discussing something similar where an internal customer's widget tree is comprised of primarily Provider widgets, making it quite user-unfriendly.

I'm seeing the correct number of Provider widgets I would expect in DartPad, so I'm not sure if this is related or not.

@elliette
Copy link
Member

Summarizing what @jacob314 just told me in the office:

In inspector_service.dart, we make the assumption that the first widget in your widget tree is owned by your application. However, @goderbauer recently landed a change to add a View widget as the first widget in the tree. (I'm seeing the View widget both in DartPad's widget tree, and in the widget tree of an internal customer that is incorrectly getting the flutter package added to their project directories.) We will need to update our detection logic to non assume that the first widget in the tree is owned by the application itself.

@goderbauer did the View widget changes make it into this latest Flutter stable release? Thanks!

@elliette
Copy link
Member

@jacob314 and I were just discussing something similar where an internal customer's widget tree is comprised of primarily Provider widgets, making it quite user-unfriendly.

Were these Provider widgets ones that they defined in their app? Or were they widgets from the internals of package:provider?

The Provider issue is separate than this - I'm pretty sure they were defined in the app, the discussion was more around whether it would make sense to filter those out (or give an option to filter them out) if a user isn't interested in seeing them in the tree view.

@goderbauer
Copy link
Member

did the View widget changes make it into this latest Flutter stable release? Thanks!

Yes, the change that adds the View widget to the root of every Flutter app made it into the stable release.

We will need to update our detection logic to non assume that the first widget in the tree is owned by the application itself.

Because of that change this assumption is now incorrect. I wasn't aware that DevTools made this assumption...

@jacob314
Copy link
Contributor

Odd that
https://github.com/flutter/devtools/blob/master/packages/devtools_app/test/inspector/inspector_service_test.dart#L96
didn't catch this issue. We should make sure those tests are still running correctly.

Good news is @elliette is working on a fix that will stop relying on the top widget in the tree being user created.
Once the fix is in it should be cherry-picked as this makes the inspector useless for CLI users.

auto-submit bot pushed a commit that referenced this issue Nov 30, 2023
Fixes #6841, #6853

Instead of using the top level widget in the widget tree to determine the project directory, we instead use the main isolate's root library. 

For google3, we also have extra logic to strip out everything before `/google3`, and to only use top-level directory after `google3` directory (or the top-level directory after `third_party`)
elliette added a commit that referenced this issue Dec 1, 2023
Fixes #6841, #6853

Instead of using the top level widget in the widget tree to determine the project directory, we instead use the main isolate's root library.

For google3, we also have extra logic to strip out everything before `/google3`, and to only use top-level directory after `google3` directory (or the top-level directory after `third_party`)
derekxu16 pushed a commit to derekxu16/devtools that referenced this issue Dec 14, 2023
Fixes flutter#6841, flutter#6853

Instead of using the top level widget in the widget tree to determine the project directory, we instead use the main isolate's root library.

For google3, we also have extra logic to strip out everything before `/google3`, and to only use top-level directory after `google3` directory (or the top-level directory after `third_party`)
derekxu16 pushed a commit to derekxu16/devtools that referenced this issue Dec 14, 2023
Fixes flutter#6841, flutter#6853

Instead of using the top level widget in the widget tree to determine the project directory, we instead use the main isolate's root library.

For google3, we also have extra logic to strip out everything before `/google3`, and to only use top-level directory after `google3` directory (or the top-level directory after `third_party`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working inspector page
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants