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

[Inspector 2.0] Stack overflow error when building the new widget tree with implementation widgets #8553

Closed
elliette opened this issue Nov 25, 2024 · 1 comment · Fixed by flutter/flutter#159454
Labels
P1 high priority issues at the top of the work list, actively being worked on. screen: inspector

Comments

@elliette
Copy link
Member

A Flutter web customer with a large widget tree reported that the new inspector is crashing for them when "show implementation widgets" is toggled on.

When it crashes, they see a "stack overflow" error in the Chrome DevTools console. I've confirmed that this is due to us building the widget tree's JSON object recursively, and it seems like we are hitting Chrome's stack limit.

They've confirmed that they don't see the stack overflow error when the widget tree JSON is built iteratively instead.

@elliette elliette added screen: inspector P1 high priority issues at the top of the work list, actively being worked on. labels Nov 25, 2024
@elliette
Copy link
Member Author

elliette commented Nov 25, 2024

Note: The iterative approach should only be used to build the widget tree itself, not to fetch any of the properties or details of a widget. This is because those require the recursive implementation to call toJsonMap for each node to get the details provided by the subclass implementations.

github-merge-queue bot pushed a commit to flutter/flutter that referenced this issue Nov 26, 2024
…esting a large widget tree (#159454)

Fixes flutter/devtools#8553

Context: 

A Flutter web customer with a large widget tree was getting a stack
overflow error when they toggled on "show implementation widgets" in the
Flutter DevTools Inspector. This is because building the JSON tree
recursively was hitting Chrome's stack limit.

This PR creates the JSON tree **iteratively** if the `getRootWidgetTree`
service extension is called with `fullDetails = false` (which is what
DevTools uses to fetch the widget tree).

For all other instances of creating a widget JSON map (for example, when
fetching widget properties) the recursive implementation is used. This
allows properties provided by subclasses implementing `toJsonMap` to be
included in the response.

Note: Because with this change `toJsonMap` is only called when
`fullDetails = true` and `toJsonMapIterative` is only called when
`fullDetails = false`, this PR partially reverts the changes in
#157309.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 high priority issues at the top of the work list, actively being worked on. screen: inspector
Projects
None yet
1 participant