migueldeicaza / SwiftTermApp

MIT License
309 stars 29 forks source link

SwiftUI crash #60

Closed migueldeicaza closed 3 years ago

migueldeicaza commented 3 years ago

Happens when going to Sessions, or returning from Sessions:

=== AttributeGraph: cycle detected through attribute 762904 ===
Simultaneous accesses to 0x600002be6d10, but modification requires exclusive access.
Previous access (a modification) started at SwiftUI`LayoutComputer.EngineDelegate.sizeThatFits(_:) + 88 (0x11ce78ec1).
Current access (a modification) started at:
0    libswiftCore.dylib                 0x000000011342fed0 swift_beginAccess + 568
1    SwiftUI                            0x000000011ce78e69 LayoutComputer.EngineDelegate.sizeThatFits(_:) + 88
2    SwiftUI                            0x000000011ce75f46 LayoutComputer.sizeThatFits(_:) + 61
3    SwiftUI                            0x000000011cdee30d StackLayout.UnmanagedImplementation.resize(_:proposal:proxy:) + 129
4    SwiftUI                            0x000000011cdeed40 specialized StackLayout.UnmanagedImplementation.sizeChildrenGenerallyWithConcreteMajorProposal(in:minorProposalForChild:) + 774
5    SwiftUI                            0x000000011cdf0862 specialized StackLayout.UnmanagedImplementation.placeChildren1(in:minorProposalForChild:) + 142
6    SwiftUI                            0x000000011cded806 StackLayout.UnmanagedImplementation.placeChildren(in:) + 112
7    SwiftUI                            0x000000011cdececb StackLayout.UnmanagedImplementation.childGeometries(at:) + 156
8    SwiftUI                            0x000000011cdece43 StackLayout.Storage.childGeometries(at:) + 111
9    SwiftUI                            0x000000011c741a54 specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 132
10   AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
11   AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
12   AttributeGraph                     0x0000000118699ae6 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 299
13   AttributeGraph                     0x00000001186b07a7 AGGraphGetValue + 210
14   SwiftUI                            0x000000011cabffd9 DynamicLayoutViewChildGeometry.childGeometries.getter + 49
15   SwiftUI                            0x000000011cac0098 DynamicLayoutViewChildGeometry.updateValue() + 224
16   SwiftUI                            0x000000011c765214 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 15
17   AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
18   AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
19   AttributeGraph                     0x0000000118699ae6 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 299
20   AttributeGraph                     0x00000001186b07a7 AGGraphGetValue + 210
21   SwiftUI                            0x000000011cffa926 AnimatableFrameAttribute.updateValue() + 39
22   SwiftUI                            0x000000011c7814cb partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 15
23   AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
24   AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
25   AttributeGraph                     0x0000000118699ae6 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 299
26   AttributeGraph                     0x00000001186b07a7 AGGraphGetValue + 210
27   SwiftUI                            0x000000011cdf82d9 SystemScrollViewAdjustedState.size.getter + 22
28   SwiftUI                            0x000000011cdf8520 SystemScrollViewAdjustedState.updateValue() + 222
29   SwiftUI                            0x000000011c779ada partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 15
30   AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
31   AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
32   AttributeGraph                     0x0000000118699ae6 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 299
33   AttributeGraph                     0x00000001186b07a7 AGGraphGetValue + 210
34   SwiftUI                            0x000000011cdf9849 UpdatedHostingScrollView.adjustedState.getter + 34
35   SwiftUI                            0x000000011cdf9930 UpdatedHostingScrollView.updateValue() + 83
36   SwiftUI                            0x000000011c779a2a partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 15
37   AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
38   AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
39   AttributeGraph                     0x0000000118699ae6 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 299
40   AttributeGraph                     0x00000001186b07a7 AGGraphGetValue + 210
41   SwiftUI                            0x000000011cdfa0ec SystemScrollViewResponder.scrollView.getter + 25
42   SwiftUI                            0x000000011cdfa1dd SystemScrollViewResponder.updateValue() + 68
43   SwiftUI                            0x000000011c77992f partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 15
44   AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
45   AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
46   AttributeGraph                     0x0000000118699ae6 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 299
47   AttributeGraph                     0x00000001186b07a7 AGGraphGetValue + 210
48   SwiftUI                            0x000000011c8abeb6 DynamicPreferenceCombiner.value.getter + 795
49   SwiftUI                            0x000000011c8ac376 protocol witness for Rule.value.getter in conformance DynamicPreferenceCombiner<A> + 23
50   AttributeGraph                     0x00000001186b3d30 dispatch thunk of Rule.value.getter + 7
51   SwiftUI                            0x000000011c7db6d5 implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 109
52   AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
53   AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
54   AttributeGraph                     0x00000001186995ce AG::Graph::value_ref(AG::AttributeID, AGSwiftMetadata const*, unsigned char&) + 128
55   AttributeGraph                     0x00000001186b07a7 AGGraphGetValue + 291
56   SwiftUI                            0x000000011c9fdbf2 ViewGraph.responderNode.getter + 61
57   SwiftUI                            0x000000011cfa739d closure #1 in ViewRendererHost.responderNode.getter + 15
58   SwiftUI                            0x000000011d1aa368 specialized thunk for @callee_guaranteed (@guaranteed ViewGraph) -> (@owned ResponderNode?) + 14
59   SwiftUI                            0x000000011cfa4af6 closure #1 in ViewRendererHost.updateViewGraph<A>(body:) + 69
60   SwiftUI                            0x000000011cf9df69 ViewRendererHost.updateViewGraph<A>(body:) + 78
61   SwiftUI                            0x000000011cf9ddbb protocol witness for ViewGraphDelegate.updateViewGraph<A>(body:) in conformance _UIHostingView<A1> + 25
62   SwiftUI                            0x000000011cf9d8d1 ViewRendererHost.responderNode.getter + 89
63   SwiftUI                            0x000000011cc41851 FocusBridge.acceptsFirstResponder.getter + 75
64   SwiftUI                            0x000000011d1dd08c _UIHostingView.canBecomeFirstResponder.getter + 45
65   SwiftUI                            0x000000011d1dd062 @objc _UIHostingView.canBecomeFirstResponder.getter + 21
66   UIKitCore                          0x0000000133623f46 -[UIResponder _canBecomeFirstResponder] + 17
67   UIKitCore                          0x00000001336244b6 -[UIResponder nextFirstResponder] + 90
68   UIKitCore                          0x00000001336212db -[UIResponder resignFirstResponder] + 206
69   SwiftTermApp                       0x000000010e338620 TerminalView.resignFirstResponder() + 96
70   SwiftTermApp                       0x000000010e338790 @objc TerminalView.resignFirstResponder() + 31
71   SwiftTermApp                       0x000000010e196320 AppTerminalView.resignFirstResponder() + 267
72   SwiftTermApp                       0x000000010e196460 @objc AppTerminalView.resignFirstResponder() + 31
73   UIKitCore                          0x0000000133b8f281 -[UIView(Hierarchy) _willMoveToWindow:] + 609
74   UIKitCore                          0x0000000133b0d987 -[UIScrollView _willMoveToWindow:] + 215
75   UIKitCore                          0x0000000133b9f32b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 446
76   SwiftTermApp                       0x000000010e09ef20 TerminalViewController.viewDidLoad() + 568
77   SwiftTermApp                       0x000000010e09fac0 @objc TerminalViewController.viewDidLoad() + 28
78   UIKitCore                          0x0000000132e22074 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 88
79   UIKitCore                          0x0000000132e2662d -[UIViewController loadViewIfRequired] + 1187
80   UIKitCore                          0x0000000132e26ebd -[UIViewController view] + 27
81   SwiftUI                            0x000000011cbca470 static PlatformViewRepresentable<>.platformView(for:) + 16
82   SwiftUI                            0x000000011cbca462 protocol witness for static PlatformViewRepresentable.platformView(for:) in conformance PlatformViewControllerRepresentableAdaptor<A> + 12
83   SwiftUI                            0x000000011d1029fd PlatformViewHost.representedView.getter + 42
84   SwiftUI                            0x000000011d10270d PlatformViewHost.updateEnvironment(_:viewPhase:focusedValues:) + 697
85   SwiftUI                            0x000000011d102f54 PlatformViewHost.init(_:host:environment:viewPhase:focusedValues:) + 718
86   SwiftUI                            0x000000011d1026b5 PlatformViewHost.__allocating_init(_:host:environment:viewPhase:focusedValues:) + 73
87   SwiftUI                            0x000000011cd3a12c closure #1 in closure #2 in closure #1 in PlatformViewChild.updateValue() + 274
88   SwiftUI                            0x000000011cd3d31e partial apply for closure #1 in closure #2 in closure #1 in PlatformViewChild.updateValue() + 92
89   SwiftUI                            0x000000011cd3d383 partial apply for thunk for @callee_guaranteed () -> (@owned PlatformViewHost<A>) + 20
90   SwiftUI                            0x000000011cd384f3 PlatformViewRepresentableValues.asCurrent<A>(do:) + 210
91   SwiftUI                            0x000000011cd3a012 closure #2 in closure #1 in PlatformViewChild.updateValue() + 224
92   SwiftUI                            0x000000011cd38d8a closure #1 in PlatformViewChild.updateValue() + 1691
93   SwiftUI                            0x000000011cd38827 PlatformViewChild.updateValue() + 628
94   SwiftUI                            0x000000011cf7ffec partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 26
95   AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
96   AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
97   AttributeGraph                     0x0000000118699ae6 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 299
98   AttributeGraph                     0x00000001186b07a7 AGGraphGetValue + 210
99   SwiftUI                            0x000000011c9ed393 AlignmentModifiedLayoutComputer.updateValue() + 33
100  SwiftUI                            0x000000011c7983f6 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 15
101  AttributeGraph                     0x00000001186933a2 AG::Graph::UpdateStack::update() + 553
102  AttributeGraph                     0x0000000118693a26 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 411
103  AttributeGraph                     0x0000000118699ae6 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 177
104  AttributeGraph                     0x00000001186b058b AGGraphGetInputValue + 236
105  SwiftUI                            0x000000011c8b4868 LayoutProxy.layoutComputer.getter + 61
106  SwiftUI                            0x000000011cbebd6e _FlexFrameLayout.sizeThatFits(in:context:child:) + 483
107  SwiftUI                            0x000000011cbec4e0 protocol witness for UnaryLayout.sizeThatFits(in:context:child:) in conformance _FlexFrameLayout + 46
108  SwiftUI                            0x000000011c9e518e closure #1 in UnaryLayoutEngine.sizeThatFits(_:) + 66
109  SwiftUI                            0x000000011c9e4d2a UnaryLayoutEngine.sizeThatFits(_:) + 738
110  SwiftUI                            0x000000011c9e53a7 protocol witness for LayoutEngineProtocol.sizeThatFits(_:) in conformance UnaryLayoutEngine<A> + 9
111  SwiftUI                            0x000000011ce78e69 LayoutComputer.EngineDelegate.sizeThatFits(_:) + 111
112  SwiftUI                            0x000000011ce75f46 LayoutComputer.sizeThatFits(_:) + 61
113  SwiftUI                            0x000000011c8b48d4 LayoutProxy.dimensions(in:) + 96
114  SwiftUI                            0x000000011d030d9f _ZStackLayout.sizeThatFits(in:context:children:) + 767
115  SwiftUI                            0x000000011d031398 protocol witness for _Layout.sizeThatFits(in:context:children:) in conformance _ZStackLayout + 17
116  SwiftUI                            0x000000011ce48b28 closure #1 in _LayoutEngine.sizeThatFits(_:) + 76
117  SwiftUI                            0x000000011ce486b1 _LayoutEngine.sizeThatFits(_:) + 769
118  SwiftUI                            0x000000011ce4987f protocol witness for LayoutEngineProtocol.sizeThatFits(_:) in conformance _LayoutEngine<A> + 9
119  SwiftUI                            0x000000011ce78e69 LayoutComputer.EngineDelegate.sizeThatFits(_:) + 111
120  SwiftUI                            0x000000011ce75f46 LayoutComputer.sizeThatFits(_:) + 61
121  SwiftUI                            0x000000011cdee30d StackLayout.UnmanagedImplementation.resize(_:proposal:proxy:) + 129
122  SwiftUI                            0x000000011cdee75c specialized StackLayout.UnmanagedImplementation.sizeChildrenIdeally(in:minorProposalForChild:) + 167
123  SwiftUI                            0x000000011cdf0862 specialized StackLayout.UnmanagedImplementation.placeChildren1(in:minorProposalForChild:) + 108
124  SwiftUI                            0x000000011cded806 StackLayout.UnmanagedImplementation.placeChildren(in:) + 112
125  SwiftUI                            0x000000011cdeca6b StackLayout.UnmanagedImplementation.sizeThatFits(_:) + 562
126  SwiftUI                            0x000000011cdec9eb StackLayout.Storage.sizeThatFits(_:) + 107
migueldeicaza commented 3 years ago

So this can happen when you have a UIView that is being surfaced to SwiftUI and you "rehost it" into another SwiftUI view that is going to be displayed and are visible at the same time.

To trigger this, I would have the iPad version running, and the menu on the left being shown, with a terminal on the right; And then you tap "Session" on the left, which would rehost the uiview to render it into the sessions display, and that would trigger a crash on the becomeFirstResponder.

There is now a bandaid that essentialy ignores the becomeFirstResponder for now in this very narrow scenario.