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

getLayoutExplorerNode stack overflow when clicking on the inspected button #5946

Closed
CoderDake opened this issue Jun 23, 2023 · 7 comments · Fixed by flutter/flutter#131486
Closed
Assignees
Labels
P1 high priority issues at the top of the work list, actively being worked on.

Comments

@CoderDake
Copy link
Contributor

  • run flutter create some_bare_app
  • cd some_bare_app
  • flutter run -d macos
  • open up the devtools link
  • start widget inspection
  • click on the plus button
  • click on the plus button again.
  • You will now get the following error:
A Dart VM Service on macOS is available at: http://127.0.0.1:60374/bj__zCuNnVg=/
The Flutter DevTools debugger and profiler on macOS is available at:
http://127.0.0.1:9103?uri=http://127.0.0.1:60374/bj__zCuNnVg=/

══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
The following StackOverflowError was thrown during a service extension callback for
"ext.flutter.inspector.getLayoutExplorerNode":
Stack Overflow

When the exception was thrown, this was the stack:
#1      _LinkedHashMapMixin._insert (dart:collection-patch/compact_hash.dart)
#2      _LinkedHashMapMixin._set (dart:collection-patch/compact_hash.dart:519:7)
#3      _LinkedHashMapMixin._init (dart:collection-patch/compact_hash.dart:440:15)
#4      _LinkedHashMapMixin._rehash (dart:collection-patch/compact_hash.dart:408:7)
#5      _LinkedHashMapMixin._insert (dart:collection-patch/compact_hash.dart:464:7)
#6      _LinkedHashMapMixin._set (dart:collection-patch/compact_hash.dart:519:7)
#7      MapBase.addAll.<anonymous closure> (dart:collection/maps.dart:41:11)
#8      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#9      DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#10     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#11     DiagnosticsProperty.toJsonMap (package:flutter/src/foundation/diagnostics.dart:2618:45)
#12     FlagProperty.toJsonMap (package:flutter/src/foundation/diagnostics.dart:2120:45)
#13     DiagnosticsNode.toJsonList.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1675:19)
#14     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#15     DiagnosticsNode.toJsonList (package:flutter/src/foundation/diagnostics.dart:1676:8)
#16     DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1637:25)
#17     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#18     WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2058:62)
#19     InspectorSerializationDelegate.additionalNodeProperties
(package:flutter/src/widgets/widget_inspector.dart:3628:53)
#20     DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#21     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#22     _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#23     WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2066:61)
#24     InspectorSerializationDelegate.additionalNodeProperties
(package:flutter/src/widgets/widget_inspector.dart:3628:53)
#25     DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#26     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#27     _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#28     WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2066:61)
#29     InspectorSerializationDelegate.additionalNodeProperties
(package:flutter/src/widgets/widget_inspector.dart:3628:53)
#30     DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#31     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#32     _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#33     WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2066:61)
#34     InspectorSerializationDelegate.additionalNodeProperties
(package:flutter/src/widgets/widget_inspector.dart:3628:53)
#35     DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#36     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#37     _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#38     WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2066:61)
#39     InspectorSerializationDelegate.additionalNodeProperties
(package:flutter/src/widgets/widget_inspector.dart:3628:53)
#40     DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#41     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#42     _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#43     WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2066:61)
...
...
#3350   DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#3351   DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#3352   _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#3353   WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2066:61)
#3354   InspectorSerializationDelegate.additionalNodeProperties
(package:flutter/src/widgets/widget_inspector.dart:3628:53)
#3355   DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#3356   DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#3357   _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#3358   WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2066:61)
#3359   InspectorSerializationDelegate.additionalNodeProperties
(package:flutter/src/widgets/widget_inspector.dart:3628:53)
#3360   DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#3361   DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#3362   _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#3363   WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>
(package:flutter/src/widgets/widget_inspector.dart:2066:61)
#3364   InspectorSerializationDelegate.additionalNodeProperties
(package:flutter/src/widgets/widget_inspector.dart:3628:53)
#3365   DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#3366   DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#3367   _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#3368   DiagnosticsNode.toJsonList.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1675:19)
#3369   ListIterator.moveNext (dart:_internal/iterable.dart:344:26)
#3370   new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#3371   new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#3372   new List.of (dart:core-patch/array_patch.dart:47:28)
#3373   ListIterable.toList (dart:_internal/iterable.dart:214:7)
#3374   DiagnosticsNode.toJsonList (package:flutter/src/foundation/diagnostics.dart:1676:8)
#3375   DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1643:23)
#3376   DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#3377   _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#3378   WidgetInspectorService._nodeToJson (package:flutter/src/widgets/widget_inspector.dart:1644:18)
#3379   WidgetInspectorService._getLayoutExplorerNode (package:flutter/src/widgets/widget_inspector.dart:2038:14)
#3380   BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:958:32)
#3390   _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
(elided 10 frames from class _AssertionError, class _Timer, dart:async, and dart:async-patch)
@CoderDake
Copy link
Contributor Author

Another way to reproduce this error appears to be scrolling up and down a widget tree with the keyboard arrows.
When I tested this it was on a smaller screen so that the widgets i was scrolling up and down to were off of the screen, and the focus needed to autoscroll to catch up.

It also appears that the current BETA does not have this issue:

Flutter 3.12.0-1.1.pre • channel beta • git@github.com:flutter/flutter.git
Framework • revision e2e0aa7037 (6 days ago) • 2023-06-20 19:48:59 -0700
Engine • revision 45712dd2f1
Tools • Dart 3.1.0 (build 3.1.0-163.1.beta) • DevTools 2.24.0

But the latest candidate does:

Flutter 3.12.0-9.0.pre • channel [user-branch] • unknown source
Framework • revision 363e2f7e0b (4 days ago) • 2023-06-22 21:11:55 -0700
Engine • revision aca26b2afc
Tools • Dart 3.1.0 (build 3.1.0-239.0.dev) • DevTools 2.24.0

@CoderDake
Copy link
Contributor Author

There are still errors on the BETA but they are not the stack overflow errors like we see on stable:
here is a snippet of some of the errors seen on BETA
ext.flutter.inspector.getDetailsSubtree: (-32000) Server error
{"exception":"type 'StatelessElement' is not a subtype of type 'DiagnosticsNode?' in type cast","stack":"#0 WidgetInspectorService._getDetailsSubtree (package:flutter/src/widgets/widget_inspector.dart:1901:48)\n#1 WidgetInspectorService.initServiceExtensions. (package:flutter/src/widgets/widget_inspector.dart:1170:21)\n#2 BindingBase.registerServiceExtension. (package:flutter/src/foundation/binding.dart:953:32)\n\n","method":"ext.flutter.inspector.getDetailsSubtree"}
chC @ main.dart.js:45536
main.dart.js:45536 [zoneGuarded]: ext.flutter.inspector.getProperties: (-32000) Server error
{"exception":"type 'StatelessElement' is not a subtype of type 'DiagnosticsNode?' in type cast","stack":"#0 WidgetInspectorService._getProperties (package:flutter/src/widgets/widget_inspector.dart:1726:63)\n#1 WidgetInspectorService._registerServiceExtensionWithArg. (package:flutter/src/widgets/widget_inspector.dart:874:35)\n#2 BindingBase.registerServiceExtension. (package:flutter/src/foundation/binding.dart:953:32)\n\n","method":"ext.flutter.inspector.getProperties"}
chC @ main.dart.js:45536
main.dart.js:5740 Uncaught Error
at Object.rq (main.dart.js:5811:24)
at main.dart.js:154875:5
at by5.a (main.dart.js:4428:62)
at by5.$2 (main.dart.js:55311:14)
at Object.m (main.dart.js:4414:10)
at yh.aAz (main.dart.js:154889:10)
at yh.cf (main.dart.js:154868:25)
at yh.ke (main.dart.js:154853:13)
at hF.ke (main.dart.js:86247:44)
at main.dart.js:91114:14
main.dart.js:45536 [zoneGuarded]: ext.flutter.inspector.getLayoutExplorerNode: (-32000) Server error
{"exception":"type 'MultiChildRenderObjectElement' is not a subtype of type 'DiagnosticsNode' in type cast","stack":"#0 WidgetInspectorService._getLayoutExplorerNode (package:flutter/src/widgets/widget_inspector.dart:2010:12)\n#1 BindingBase.registerServiceExtension. (package:flutter/src/foundation/binding.dart:953:32)\n\n","method":"ext.flutter.inspector.getLayoutExplorerNode"}
chC @ main.dart.js:45536
main.dart.js:5740 Uncaught Error
at Object.rq (main.dart.js:5811:24)
at main.dart.js:154875:5
at by5.a (main.dart.js:4428:62)
at by5.$2 (main.dart.js:55311:14)
at Object.m (main.dart.js:4414:10)
at yh.aAz (main.dart.js:154889:10)
at yh.cf (main.dart.js:154868:25)
at yh.ke (main.dart.js:154853:13)
at hF.ke (main.dart.js:86247:44)
at main.dart.js:91114:14
main.dart.js:45536 ext.flutter.inspector.getDetailsSubtree: (-32000) Server error
{"exception":"type 'StatelessElement' is not a subtype of type 'DiagnosticsNode?' in type cast","stack":"#0 WidgetInspectorService._getDetailsSubtree (package:flutter/src/widgets/widget_inspector.dart:1901:48)\n#1 WidgetInspectorService.initServiceExtensions. (package:flutter/src/widgets/widget_inspector.dart:1170:21)\n#2 BindingBase.registerServiceExtension. (package:flutter/src/foundation/binding.dart:953:32)\n\n","method":"ext.flutter.inspector.getDetailsSubtree"}
chC @ main.dart.js:45536
main.dart.js:45536 [zoneGuarded]: ext.flutter.inspector.getProperties: (-32000) Server error
{"exception":"type 'StatelessElement' is not a subtype of type 'DiagnosticsNode?' in type cast","stack":"#0 WidgetInspectorService._getProperties (package:flutter/src/widgets/widget_inspector.dart:1726:63)\n#1 WidgetInspectorService._registerServiceExtensionWithArg. (package:flutter/src/widgets/widget_inspector.dart:874:35)\n#2 BindingBase.registerServiceExtension. (package:flutter/src/foundation/binding.dart:953:32)\n\n","method":"ext.flutter.inspector.getProperties"}

@polina-c polina-c self-assigned this Jun 26, 2023
@polina-c polina-c added the P3 label Jun 26, 2023
@polina-c
Copy link
Contributor

polina-c commented Jun 26, 2023

Repeating part:

#19     InspectorSerializationDelegate.additionalNodeProperties (package:flutter/src/widgets/widget_inspector.dart:3628:53)
#20     DiagnosticsNode.toJsonMap.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1635:21)
#21     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1650:6)
#22     _ElementDiagnosticableTreeNode.toJsonMap (package:flutter/src/widgets/framework.dart:5052:45)
#23     WidgetInspectorService._getLayoutExplorerNode.<anonymous closure>(package:flutter/src/widgets/widget_inspector.dart:2066:61)
#24     InspectorSerializationDelegate.additionalNodeProperties

@kenzieschmoll kenzieschmoll added P1 high priority issues at the top of the work list, actively being worked on. and removed P3 labels Jul 5, 2023
@CoderDake CoderDake self-assigned this Jul 7, 2023
@polina-c polina-c removed their assignment Jul 7, 2023
@CoderDake
Copy link
Contributor Author

CoderDake commented Jul 27, 2023

it looks like clicking on a single element triggers 10s of thousands of calls to additional node props.
there are certain large culprits. For example clicking on the floating action button in the devtools widget tree trigger ~150k calls to additionalNodeProperties.
It then throws a stack overflow.
So perhaps there is something about that specific element that recurses?

@CoderDake
Copy link
Contributor Author

Looking into this more I used a static hash to keep track of the DiagnosticsNode objects that we were looking through.
I was able to find out that the FloatingActionButton keeps getting looped through. So somehow it keeps coming back to itself

@CoderDake
Copy link
Contributor Author

Diving even deeper, it looks like it is the Tooltip that causes a loop.
I can reproduce this my wrapping a text element with a tooltip and then inspecting that text element

@CoderDake
Copy link
Contributor Author

Jacob mentions that we may just not want to go deeper for RenderObjects Instead

CoderDake added a commit to flutter/flutter that referenced this issue Aug 2, 2023
…1486)

![](https://media.giphy.com/media/l0ExdBwqD6YkeEhQ4/giphy-downsized.gif)

Fixes flutter/devtools#5946

While preparing DevTools for the Multi View changes, I noticed that
inspecting a Tooltip causes an stack overflow.
This PR addresses that issue by fixing the scope of the subtreeDepth variable and adding some other idiomatic fixes
vashworth pushed a commit to vashworth/flutter that referenced this issue Aug 2, 2023
…tter#131486)

![](https://media.giphy.com/media/l0ExdBwqD6YkeEhQ4/giphy-downsized.gif)

Fixes flutter/devtools#5946

While preparing DevTools for the Multi View changes, I noticed that
inspecting a Tooltip causes an stack overflow.
This PR addresses that issue by fixing the scope of the subtreeDepth variable and adding some other idiomatic fixes
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.
Projects
None yet
3 participants