Wordpress-ios: iOS 12: NSInternalInconsistencyException

Created on 29 Oct 2018  ·  11Comments  ·  Source: wordpress-mobile/WordPress-iOS

This one seems to happen on iOS 12 only.
It's been registered for a while now, but it's becoming a lot more common now that iOS 12 has been widely adopted.

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x1f333aef8 __exceptionPreprocess
1  libobjc.A.dylib                0x1f2508a40 objc_exception_throw
2  CoreFoundation                 0x1f324f06c +[_CFXNotificationTokenRegistration keyCallbacks]
3  Foundation                     0x1f3d3b3e0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4  UIKitCore                      0x21f596314 -[UICollectionViewFlowLayout _getSizingInfosWithExistingSizingDictionary:]
5  UIKitCore                      0x21f59782c -[UICollectionViewFlowLayout _fetchItemsInfoForRect:]
6  UIKitCore                      0x21f591680 -[UICollectionViewFlowLayout prepareLayout]
7  UIKitCore                      0x21f589ea4 -[UICollectionViewData _prepareToLoadData]
8  UIKitCore                      0x21f58a6e4 -[UICollectionViewData validateLayoutInRect:]
9  UIKitCore                      0x21f55e56c -[UICollectionView layoutSubviews]
10 UIKitCore                      0x220127f44 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
11 QuartzCore                     0x1f791ca34 -[CALayer layoutSublayers]
12 QuartzCore                     0x1f79219c4 CA::Layer::layout_if_needed(CA::Transaction*)
13 QuartzCore                     0x1f78809d4 CA::Context::commit_transaction(CA::Transaction*)
14 QuartzCore                     0x1f78af2f4 CA::Transaction::commit()
15 QuartzCore                     0x1f78b015c CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
16 CoreFoundation                 0x1f32c8b94 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
17 CoreFoundation                 0x1f32c3828 __CFRunLoopDoObservers
18 CoreFoundation                 0x1f32c3dc8 __CFRunLoopRun
19 CoreFoundation                 0x1f32c35b8 CFRunLoopRunSpecific
20 GraphicsServices               0x1f5537584 GSEventRunModal
21 UIKitCore                      0x21fc84bc8 UIApplicationMain
22 WordPress                      0x1000c0444 main (main.m:11)
23 libdyld.dylib                  0x1f2d83b94 start

5b6bceae6007d59fcd4084ef-fabric

[Pri] High [Type] Crash

Most helpful comment

@loremattei yes please! 🙏

All 11 comments

Do you have a fix for this?

@atul3189 – not yet, but pull requests are welcome!

I have the same crash on iOS12 only

@xuhaoranLeo do you happen to be able to share some steps for reproducing it?

I have crashes with this as well, but in a different app. Any ideas?

@loremattei , investigating this bug a bit it seems like somehow it is possible (maybe due to a bug in UIKit) that one of the SizeForItemAtIndexPath on a collection view is returning a negative size though from a quick look at the code, it doesn't seem like we are returning possible negatives anywhere.
Either we are returning the collection view's frame width or 0.

I was able to reproduce the exact crash by returning negative value for one of the dimensions in the mentioned delegate call.

Do you know where this crash happens?

I'm thinking I can add max(0, width) and max(0, height) in all the places we return size for that delegate method, as a preliminary action but not sure how to test it as I don't get this crash naturally.

Any thoughts on this?

Hey @yaelirub thank you for tackling this one!
I see that you shifted to addressing the NaN case in the PR. It looks like a good attempt to me and I actually agree to go for it as the first attempt.
If it doesn't fix the issue, we could then try to address to negative numbers case, but I agree with you that it doesn't seem possible that a negative number is passed there, so let's leave it as the last resort :-)

One similar issue we've seen with odd layout geometry: https://github.com/wordpress-mobile/WordPress-iOS/pull/10578

It wouldn't be the first time we've added a check like this 🙂

@loremattei , yeah addressing NaN made more sense to me here.
What do you think then? Do you approve?

Yep! Sure!!! Sorry if it was not clear :-)
Do you want me to review the PR?

@loremattei yes please! 🙏

Was this page helpful?
0 / 5 - 0 ratings