guoyingtao / Mantis

An iOS Image cropping library, which mimics the Photo App written in Swift.
MIT License
900 stars 180 forks source link

Fatal Exception: CALayerInvalidGeometry #166

Closed tdc-peter closed 1 year ago

tdc-peter commented 2 years ago

Crash report...

Version 1.8.0

I cannot reproduce it yet. But it is important to keep track of it. As my investigation continues I will update this issue.

Fatal Exception: CALayerInvalidGeometry

CALayer bounds contains NaN: [0 0; nan nan]. Layer: <CALayer:0x28267fb00; position = CGPoint (0 0); bounds = CGRect (0 0; 0 0); delegate = <Mantis.CropScrollView: 0x107978e00; baseClass = UIScrollView; frame = (0 0; 0 0); gestureRecognizers = <NSArray: 0x2829a2130>; layer = <CALayer: 0x28267fb00>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}>; sublayers = (<CALayer: 0x28267f280>); opaque = YES; allowsGroupOpacity = YES; anchorPoint = CGPoint (0.5 0.5)>
Fatal Exception: CALayerInvalidGeometry
0   CoreFoundation                 0x99d78 __exceptionPreprocess
1   libobjc.A.dylib                0x16734 objc_exception_throw
2   CoreFoundation                 0xf1024 __CFDictionaryCreateGeneric
3   QuartzCore                     0x23a10 CA::Layer::set_bounds(CA::Rect const&, bool)
4   QuartzCore                     0xc8480 -[CALayer setBounds:]
5   UIKitCore                      0x16b8d0 -[UIView(Geometry) setBounds:]
6   UIKitCore                      0x178530 -[UIScrollView setBounds:]

7   APP                         0x14bb98 specialized CropView.adjustUIForNewCrop(contentRect:animation:zoom:completion:) + 471 (<compiler-generated>:471)
8   APP                         0x148098 CropView.setFixedRatioCropBox(zoom:cropBox:) (<compiler-generated>)
9   APP                         0x152b4c CropViewController.setFixedRatio(_:zoom:) + 236 (CropViewController.swift:236)
10  APP                         0x1517fc CropViewController.createCropToolbar() + 117 (CropViewController.swift:117)
11  APP                         0x151da4 CropViewController.viewDidLoad() + 172 (CropViewController.swift:172)
12  APP                         0x15234c @objc CropViewController.viewDidLoad() (<compiler-generated>)

13  UIKitCore                      0x1ab6c4 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled]
14  UIKitCore                      0x1ae214 -[UIViewController loadViewIfRequired]
15  UIKitCore                      0x181274 -[UIViewController view]
16  SwiftUI                        0xb5004 static PlatformViewRepresentable<>.platformView(for:)
17  SwiftUI                        0x185ca4 protocol witness for static PlatformViewRepresentable.platformView(for:) in conformance PlatformViewControllerRepresentableAdaptor<A>
18  SwiftUI                        0x662f0 PlatformViewHost.representedView.getter
19  SwiftUI                        0xf8378 PlatformViewHost.updateEnvironment(_:viewPhase:focusedValues:)
20  SwiftUI                        0xe62f4 PlatformViewHost.init(_:host:environment:viewPhase:focusedValues:)
21  SwiftUI                        0x14c230 PlatformViewHost.__allocating_init(_:host:environment:viewPhase:focusedValues:)
22  SwiftUI                        0xd1e1c closure #1 in closure #2 in closure #1 in PlatformViewChild.updateValue()
23  SwiftUI                        0x10ee44 partial apply for closure #1 in closure #2 in closure #1 in PlatformViewChild.updateValue()
24  SwiftUI                        0xb9974 PlatformViewRepresentableValues.asCurrent<A>(do:)
25  SwiftUI                        0xc2e04 closure #2 in closure #1 in PlatformViewChild.updateValue()
26  SwiftUI                        0x6a614 closure #1 in PlatformViewChild.updateValue()
27  SwiftUI                        0xa12f0 partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
28  AttributeGraph                 0x3b18 AG::Graph::UpdateStack::update()
29  AttributeGraph                 0x3508 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
30  AttributeGraph                 0x42f8 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
31  AttributeGraph                 0x1e54 AGGraphGetValue
32  SwiftUI                        0x9f670 AlignmentModifiedLayoutComputer.updateValue()
33  SwiftUI                        0xc799c partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
34  AttributeGraph                 0x3b18 AG::Graph::UpdateStack::update()
35  AttributeGraph                 0x3508 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
36  AttributeGraph                 0x42f8 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
37  AttributeGraph                 0x5fd0 AGGraphGetInputValue
38  SwiftUI                        0x52854 StackLayout.Header.init(layoutContext:proxies:majorAxis:minorAxisAlignment:uniformSpacing:childStorage:capacity:resizeChildrenWithTrailingOverflow:)
39  SwiftUI                        0x11a208 specialized ManagedBufferPointer.init(bufferClass:minimumCapacity:makingHeaderWith:)
40  SwiftUI                        0x3d5968 specialized closure #2 in HVStack.updateLayoutComputer<A>(rule:layoutContext:children:)
41  SwiftUI                        0x425d84 specialized closure #2 in HVStack.updateLayoutComputer<A>(rule:layoutContext:children:)
42  SwiftUI                        0x46dce4 partial apply for specialized closure #2 in HVStack.updateLayoutComputer<A>(rule:layoutContext:children:)
43  SwiftUI                        0x161048 specialized static LayoutComputerDelegate.update<A>(_:maybeInPlace:create:)
44  SwiftUI                        0x142a08 specialized StatefulRule<>.updateLayoutComputer<A>(layout:environment:layoutComputers:)
45  SwiftUI                        0x106ba0 specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
46  SwiftUI                        0xfe544 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
47  AttributeGraph                 0x3b18 AG::Graph::UpdateStack::update()
48  AttributeGraph                 0x3508 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
49  AttributeGraph                 0x425c AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
50  AttributeGraph                 0x5fd0 AGGraphGetInputValue
51  SwiftUI                        0x77ea4 LayoutProxy.layoutComputer.getter
52  SwiftUI                        0x6b1800 _PaddingLayout.sizeThatFits(in:context:child:)
53  SwiftUI                        0x6b1944 protocol witness for UnaryLayout.sizeThatFits(in:context:child:) in conformance _PaddingLayout
54  SwiftUI                        0x6b7d5c closure #1 in UnaryLayoutEngine.sizeThatFits(_:)
55  SwiftUI                        0x6b7c40 UnaryLayoutEngine.sizeThatFits(_:)
56  SwiftUI                        0xb0c2ec LayoutComputer.EngineDelegate.sizeThatFits(_:)
57  SwiftUI                        0x4d3a4 StackLayout.UnmanagedImplementation.resize(_:proposal:proxy:)
58  SwiftUI                        0x6d2f0 specialized StackLayout.UnmanagedImplementation.sizeChildrenGenerallyWithConcreteMajorProposal(in:minorProposalForChild:)
59  SwiftUI                        0x9da48 specialized StackLayout.UnmanagedImplementation.placeChildren1(in:minorProposalForChild:)
60  SwiftUI                        0x7f2e8 StackLayout.UnmanagedImplementation.placeChildren(in:)
61  SwiftUI                        0xa7defc StackLayout.UnmanagedImplementation.sizeThatFits(_:)
62  SwiftUI                        0xa7dd9c StackLayout.Storage.sizeThatFits(_:)
63  SwiftUI                        0x1329f8 RootGeometry.value.getter
64  SwiftUI                        0x934d4 specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
65  SwiftUI                        0x4104c partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
66  AttributeGraph                 0x3b18 AG::Graph::UpdateStack::update()
67  AttributeGraph                 0x3508 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
68  AttributeGraph                 0x42f8 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
69  AttributeGraph                 0x1e54 AGGraphGetValue
70  SwiftUI                        0x9ce90 specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
71  AttributeGraph                 0x3b18 AG::Graph::UpdateStack::update()
72  AttributeGraph                 0x3508 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
73  AttributeGraph                 0x42f8 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
74  AttributeGraph                 0x1e54 AGGraphGetValue
75  SwiftUI                        0x78b14 DynamicLayoutViewChildGeometry.childGeometries.getter
76  SwiftUI                        0x128528 DynamicLayoutViewChildGeometry.updateValue()
77  SwiftUI                        0x934a8 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
78  AttributeGraph                 0x3b18 AG::Graph::UpdateStack::update()
79  AttributeGraph                 0x3508 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
80  AttributeGraph                 0x42f8 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
81  AttributeGraph                 0x1e54 AGGraphGetValue
82  SwiftUI                        0xbdea4 AnimatableFrameAttribute.updateValue()
83  SwiftUI                        0x113744 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
84  AttributeGraph                 0x3b18 AG::Graph::UpdateStack::update()
85  AttributeGraph                 0x3508 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
86  AttributeGraph                 0x2318 AG::Subgraph::update(unsigned int)
87  SwiftUI                        0x5b38 ViewGraph.updateOutputs()
88  SwiftUI                        0x3e47d4 specialized closure #1 in ViewRendererHost.render(interval:updateDisplayList:)
89  SwiftUI                        0x3e3eb4 specialized closure #1 in ViewRendererHost.render(interval:updateDisplayList:)
90  SwiftUI                        0x309ce8 specialized ViewRendererHost.render(interval:updateDisplayList:)
91  SwiftUI                        0x7d5340 closure #1 in withUpdatedNavigationBar #1 <A>(perform:) in NavigationBridge_PhoneTV.push(_:onto:animated:)
92  SwiftUI                        0x7d6a40 partial apply for closure #1 in withUpdatedNavigationBar #1 <A>(perform:) in NavigationBridge_PhoneTV.push(_:onto:animated:)
93  SwiftUI                        0x113eb4 thunk for @escaping @callee_guaranteed () -> ()
94  SwiftUI                        0x172c4 closure #1 in ViewRendererHost.render(interval:updateDisplayList:)
95  SwiftUI                        0xded5c ViewRendererHost.render(interval:updateDisplayList:)
96  SwiftUI                        0x590c4c closure #1 in _UIHostingView.requestImmediateUpdate()
97  SwiftUI                        0x566e0 thunk for @escaping @callee_guaranteed () -> ()
98  libdispatch.dylib              0x1e68 _dispatch_call_block_and_release
99  libdispatch.dylib              0x3a2c _dispatch_client_callout
100 libdispatch.dylib              0x11f48 _dispatch_main_queue_drain
101 libdispatch.dylib              0x11b98 _dispatch_main_queue_callback_4CF
102 CoreFoundation                 0x522f0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
103 CoreFoundation                 0xc1f4 __CFRunLoopRun
104 CoreFoundation                 0x1f6b8 CFRunLoopRunSpecific
105 GraphicsServices               0x1374 GSEventRunModal
106 UIKitCore                      0x513e88 -[UIApplication _run]
107 UIKitCore                      0x2955ec UIApplicationMain
108 libswiftUIKit.dylib            0x30ecc UIApplicationMain(_:_:_:_:)
109 APP                         0x5884 main (BackButton.swift)
110 ???                            0x105835ce4 (Missing)
guoyingtao commented 2 years ago

@CITPeter Thanks for the report! I will do more tests on it when I get a chance.

tdc-peter commented 1 year ago

@guoyingtao still an issue with version 2.8

I have added some logging to the app to see how much is used.. and size detail from images people crop. No clear indicator what goes wrong unfortunately.

Events/Users that use the Crop functionality: 959 events - 297 users

Crashes: 54 events - 38 users

Log:

Fatal Exception: CALayerInvalidGeometry
0   CoreFoundation                 0x9e38 __exceptionPreprocess
1   libobjc.A.dylib                0x178d8 objc_exception_throw
2   CoreFoundation                 0xf9c28 __CFDictionaryCreateGeneric
3   QuartzCore                     0x27974 CA::Layer::set_bounds(CA::Rect const&, bool)
4   QuartzCore                     0xece4 -[CALayer setBounds:]
5   UIKitCore                      0x31b28 -[UIView(Geometry) setBounds:]
6   UIKitCore                      0x318c8 -[UIScrollView setBounds:]
7   AppName                         0x17b090 specialized CropView.adjustUIForNewCrop(contentRect:animation:zoom:completion:) + 495 (CropView.swift:495)
8   AppName                         0x175a98 CropView.setFixedRatioCropBox(zoom:cropBox:) (<compiler-generated>)
9   AppName                         0x179198 CropView.setFixedRatio(_:zoom:presetFixedRatioType:) + 802 (CropView.swift:802)
10  AppName                         0x183000 CropViewController.createCropToolbar() (<compiler-generated>)
11  AppName                         0x1834c0 CropViewController.viewDidLoad() + 131 (CropViewController.swift:131)
12  AppName                         0x183b00 @objc CropViewController.viewDidLoad() (<compiler-generated>)
13  UIKitCore                      0x38205c -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled]
14  UIKitCore                      0x1a35c -[UIViewController loadViewIfRequired]
15  UIKitCore                      0x1a074 -[UIViewController view]
16  SwiftUI                        0x9da34 OUTLINED_FUNCTION_867
17  SwiftUI                        0x14300c OUTLINED_FUNCTION_684
18  SwiftUI                        0x6078c OUTLINED_FUNCTION_244
19  SwiftUI                        0x1492f7c OUTLINED_FUNCTION_2
20  SwiftUI                        0x1493e9c OUTLINED_FUNCTION_2
21  SwiftUI                        0x1493080 OUTLINED_FUNCTION_2
22  SwiftUI                        0xe3e9b8 OUTLINED_FUNCTION_0
23  SwiftUI                        0xe419d0 OUTLINED_FUNCTION_0
24  SwiftUI                        0xa1d00 OUTLINED_FUNCTION_513
25  SwiftUI                        0xe3e7d0 OUTLINED_FUNCTION_0
26  SwiftUI                        0xe3da00 OUTLINED_FUNCTION_0
27  SwiftUI                        0x8faf8 OUTLINED_FUNCTION_1160
28  AttributeGraph                 0x46f4 AG::Graph::UpdateStack::update()
29  AttributeGraph                 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
30  AttributeGraph                 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
31  AttributeGraph                 0x271c AGGraphGetValue
32  SwiftUI                        0x138820 __swift_allocate_value_buffer
33  SwiftUI                        0x77118 OUTLINED_FUNCTION_123
34  SwiftUI                        0x8faf8 OUTLINED_FUNCTION_1160
35  AttributeGraph                 0x46f4 AG::Graph::UpdateStack::update()
36  AttributeGraph                 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
37  AttributeGraph                 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
38  AttributeGraph                 0x7188 AGGraphGetInputValue
39  SwiftUI                        0xf92ca0 OUTLINED_FUNCTION_14
40  SwiftUI                        0x356e18 OUTLINED_FUNCTION_1
41  SwiftUI                        0x3561a0 OUTLINED_FUNCTION_1
42  SwiftUI                        0x4cf5ac OUTLINED_FUNCTION_1
43  SwiftUI                        0x3592f4 OUTLINED_FUNCTION_1
44  SwiftUI                        0x298ef4 OUTLINED_FUNCTION_1
45  SwiftUI                        0xdd91c __swift_memcpy28_4
46  SwiftUI                        0xd7e74 -[TimeProvider .cxx_destruct]
47  AttributeGraph                 0x46f4 AG::Graph::UpdateStack::update()
48  AttributeGraph                 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
49  AttributeGraph                 0x4ff0 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
50  AttributeGraph                 0x7188 AGGraphGetInputValue
51  SwiftUI                        0x6ee98 OUTLINED_FUNCTION_112
52  SwiftUI                        0x95e944 OUTLINED_FUNCTION_1
53  SwiftUI                        0x95eb38 OUTLINED_FUNCTION_1
54  SwiftUI                        0x96b51c OUTLINED_FUNCTION_8
55  SwiftUI                        0x96b3f4 OUTLINED_FUNCTION_8
56  SwiftUI                        0x1087378 OUTLINED_FUNCTION_61
57  SwiftUI                        0xf94db4 OUTLINED_FUNCTION_14
58  SwiftUI                        0xf93e18 OUTLINED_FUNCTION_14
59  SwiftUI                        0xf96344 OUTLINED_FUNCTION_14
60  SwiftUI                        0xf93b90 OUTLINED_FUNCTION_14
61  SwiftUI                        0x147b18c OUTLINED_FUNCTION_20
62  SwiftUI                        0x147b6ec OUTLINED_FUNCTION_20
63  SwiftUI                        0xb0d1bc OUTLINED_FUNCTION_77
64  SwiftUI                        0x1087378 OUTLINED_FUNCTION_61
65  SwiftUI                        0xfea4c OUTLINED_FUNCTION_491
66  SwiftUI                        0xd2ffc OUTLINED_FUNCTION_1257
67  SwiftUI                        0x419cc OUTLINED_FUNCTION_105
68  AttributeGraph                 0x46f4 AG::Graph::UpdateStack::update()
69  AttributeGraph                 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
70  AttributeGraph                 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
71  AttributeGraph                 0x271c AGGraphGetValue
72  SwiftUI                        0x8bccc OUTLINED_FUNCTION_134
73  AttributeGraph                 0x46f4 AG::Graph::UpdateStack::update()
74  AttributeGraph                 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
75  AttributeGraph                 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
76  AttributeGraph                 0x271c AGGraphGetValue
77  SwiftUI                        0x6f9a4 OUTLINED_FUNCTION_71
78  SwiftUI                        0xf4cec OUTLINED_FUNCTION_1125
79  SwiftUI                        0x837c8 OUTLINED_FUNCTION_120
80  AttributeGraph                 0x46f4 AG::Graph::UpdateStack::update()
81  AttributeGraph                 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
82  AttributeGraph                 0x5088 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
83  AttributeGraph                 0x271c AGGraphGetValue
84  SwiftUI                        0x12cff80 OUTLINED_FUNCTION_0
85  SwiftUI                        0x54e9ec objectdestroy.6496Tm
86  AttributeGraph                 0x46f4 AG::Graph::UpdateStack::update()
87  AttributeGraph                 0x3f44 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
88  AttributeGraph                 0x2c00 AG::Subgraph::update(unsigned int)
89  SwiftUI                        0xd2cc OUTLINED_FUNCTION_15
90  SwiftUI                        0x1c754 OUTLINED_FUNCTION_157
91  SwiftUI                        0xbdf48 OUTLINED_FUNCTION_450
92  SwiftUI                        0x7b37fc OUTLINED_FUNCTION_2
93  SwiftUI                        0x52b3c OUTLINED_FUNCTION_764
94  libdispatch.dylib              0x2460 _dispatch_call_block_and_release
95  libdispatch.dylib              0x3f88 _dispatch_client_callout
96  libdispatch.dylib              0x127f4 _dispatch_main_queue_drain
97  libdispatch.dylib              0x12444 _dispatch_main_queue_callback_4CF
98  CoreFoundation                 0x9a6c8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
99  CoreFoundation                 0x7c02c __CFRunLoopRun
100 CoreFoundation                 0x80eb0 CFRunLoopRunSpecific
101 GraphicsServices               0x1368 GSEventRunModal
102 UIKitCore                      0x3a1668 -[UIApplication _run]
103 UIKitCore                      0x3a12cc UIApplicationMain
104 libswiftUIKit.dylib            0x35308 UIApplicationMain(_:_:_:_:)
105 AppName                         0x7458 main (BackButton.swift)
106 ???                            0x1a91c8960 (Missing)
guoyingtao commented 1 year ago

Hi @7blueXY I released Mantis 2.9.1 which add more guard logics for this issue. Can you have a try to see if it solves the issue? Thanks!

tdc-peter commented 1 year ago

@guoyingtao thank you! Will add this to next release of the app, which will be probably next week.

guoyingtao commented 1 year ago

@7blueXY Has the new version solved the issue?

tdc-peter commented 1 year ago

@guoyingtao the app is in production for a week or two. People are slowly updating... so will have a more clear answer in two weeks, but but, no crashes are reported since updating so the signs are good :)

Thanks again for looking into this crash report!

tdc-peter commented 1 year ago

I have not seen any crash reports after updating to 2.9.1. So this issue is closed! Thanks again!