Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

App Crashes with unrecognized selector #66

Open
krunalsheth opened this issue Jul 25, 2016 · 8 comments
Open

App Crashes with unrecognized selector #66

krunalsheth opened this issue Jul 25, 2016 · 8 comments

Comments

@krunalsheth
Copy link

here's the stack

UICollectionView swizzledDescription]: unrecognized selector sent to instance 0x7f993b87b200
2016-07-25 00:19:29.932 <>[5159:3383980] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionView swizzledDescription]: unrecognized selector sent to instance 0x7f993b87b200'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107d88d85 exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001077fcdeb objc_exception_throw + 48
2 CoreFoundation 0x0000000107d91d3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000107cd7cfa __forwarding
+ 970
4 CoreFoundation 0x0000000107cd78a8 _CF_forwarding_prep_0 + 120
5 TouchVisualizer 0x00000001060cf5dc _TFE15TouchVisualizerCSo8UIWindow19swizzledDescriptionfT_SS + 28
6 TouchVisualizer 0x00000001060cf6c2 _TToFE15TouchVisualizerCSo8UIWindow19swizzledDescriptionfT_SS + 34
7 UIKit 0x00000001061e3792 -[UIScrollView description] + 49
8 UIKit 0x00000001069831ee -[UICollectionView description] + 45
9 Foundation 0x0000000105676617 _NSDescriptionWithLocaleFunc + 91
10 CoreFoundation 0x0000000107c74bdc __CFStringAppendFormatCore + 9708
11 CoreFoundation 0x0000000107d64a03 _CFStringCreateWithFormatAndArgumentsAux2 + 259
12 CoreFoundation 0x0000000107d7593a _CFLogvEx2 + 154
13 CoreFoundation 0x0000000107d75a9b _CFLogvEx3 + 171
14 Foundation 0x000000010574db1e _NSLogv + 117
15 Foundation 0x000000010569c822 NSLog + 152
16 UIKit 0x0000000106a1cd0d -[_UIFlowLayoutSection logInvalidSizesForHorizontalDirection:warnAboutDelegateValues:] + 191
17 UIKit 0x0000000106a1afe4 -[_UIFlowLayoutSection computeLayout] + 951
18 UIKit 0x00000001069c892a __56-[UICollectionViewFlowLayout _updateItemsLayoutForRect:]_block_invoke + 107
19 CoreFoundation 0x0000000107cb0d32 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
20 CoreFoundation 0x0000000107cb0422 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 194
21 UIKit 0x00000001069c87ed -[UICollectionViewFlowLayout _updateItemsLayoutForRect:] + 575
22 UIKit 0x00000001069c8c80 -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 175
23 UIKit 0x00000001069c23fd -[UICollectionViewFlowLayout prepareLayout] + 273
24 UIKit 0x00000001069e2c3d -[UICollectionViewData _prepareToLoadData] + 67
25 UIKit 0x00000001069e3411 -[UICollectionViewData validateLayoutInRect:] + 53
26 UIKit 0x000000010699053a -[UICollectionView layoutSubviews] + 199
27 UIKit 0x00000001061cb980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
28 QuartzCore 0x0000000105d4dc00 -[CALayer layoutSublayers] + 146
29 QuartzCore 0x0000000105d4208e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
30 QuartzCore 0x0000000105d41f0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
31 QuartzCore 0x0000000105d363c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
32 QuartzCore 0x0000000105d64086 _ZN2CA11Transaction6commitEv + 486
33 QuartzCore 0x0000000105d647f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
34 CoreFoundation 0x0000000107cadc37 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
35 CoreFoundation 0x0000000107cadba7 __CFRunLoopDoObservers + 391
36 CoreFoundation 0x0000000107ca37fb __CFRunLoopRun + 1147
37 CoreFoundation 0x0000000107ca30f8 CFRunLoopRunSpecific + 488
38 GraphicsServices 0x000000010a279ad2 GSEventRunModal + 161
39 UIKit 0x0000000106110f09 UIApplicationMain + 171
40 <> 0x000000010393c2c2 main + 114
41 libdyld.dylib 0x00000001087e592d start + 1
42 ??? 0x0000000000000001 0x0 + 1
)

@morizotter
Copy link
Owner

Thanks for your backlogs!

@krunalsheth
Copy link
Author

can you please explain why is swizzledDescription there in first place? what purpose does it serve?

@morizotter
Copy link
Owner

morizotter commented Jul 26, 2016

When application becomes active, UIWindow's swizzle() method would be called. At that time, TouchVisualizer switches sendEvent with the custom sendEvent. But if this swizzle() method were called multiple times, it would switch methods again. To prevent this behavior, I created swizzlingMessage and changed description.

When swizzle() are called, checks if description contains this message first. And do nothing if description contains this swizzlingMessage . This is a hack. But there have to be a better way...

@krunalsheth

@krunalsheth
Copy link
Author

okay i see that in code now. I am new to "method swizzling" . so this may be a naive question. can you please explain why the "swizzle" needs to happen only when application becomes active? can't you do the same when Visualizer.start is called? with the current implementation, TouchVisualizer doesn't work if someone calls Visualizer.start long after application is started (imagine you have a "presentation mode" switch in the app and you want to show TouchVisualizer only when someone turns the switch) @morizotter

@morizotter
Copy link
Owner

morizotter commented Jul 26, 2016

can you please explain why the "swizzle" needs to happen only when application becomes active?

I think it is because when user write Visualizer.start() in application: didFinishLaunchingWithOptions: it was too late because UIWindow maybe create after Visuzlizer.star(). At first stage of this library, Visualizer.start() is supposed to write in application:didFinish....

@krunalsheth
Copy link
Author

@morizotter are you saying Visualizer.start() need to be called only during application:didFinish? if so, i think documentation needs to be updated.

my original question was, can the code to swizzle be called inside Visualizer.start ? would that not work?

@zarghol
Copy link

zarghol commented Sep 20, 2016

have the same problem in iOS 10 when I try to perform a segue (custom transition).
I fixed it but since I wait for merge the pull request for iOS 10, I can't send it unitary.
here it is : zarghol@dbaafdf

@lm2343635
Copy link
Contributor

I have same problem in my app.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants