CALayerInvalidGeometry crash on iOS9 “sublayer wit

2019-04-10 17:42发布

问题:

iOS 9, Swift 2: I've got a view controller with a custom view that crashes whenever I pop it from it's navigation controller stack, citing the following crash:

 *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'sublayer with non-finite position [inf inf]'

There is far too much going on in the view controller to post here (it's what i'm in the middle of cleaning up) but was wondering if anyone has experienced a similar issue?

I've seen sublayer with non-finite position [inf inf] and a related question, but neither resolve the problem. There is no CGRectNull to be found in the entire code base, so i'm a bit stumped.

回答1:

And of course as soon as I post the question after 30 minutes of struggling, I finally crack it.

There were a whole bunch of subViews that were being added to the view elsewhere in the view controller that I wasn't aware of. The main view is using constraints based layout while these subviews were being created with a frame and then added as a subview.

I'm not sure why it was causing a crash, but after removing all the rogue subviews all was well.

I'll keep this question/answer alive in case anyone else has the same issue.