Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug crashes with the message "outlined copy of Optional"?

Tags:

ios

swift

I have a Swift 4 app and all of a sudden I started getting many crashes logged with the message outlined copy of Account?. There are a couple different files referenced in the stack trace, though it most frequently happens in the app's entry point.

I have been unable to reproduce the error. Every instance of the crash has occurred in iOS 10.3.3, which is not available from Apple as a simulator download. I can also not find any mention of this error message aside from one Twitter thread, which ends with "I forgot how I fixed this".

Has anybody seen this and been able to fix it? Here is a bit of the stack trace. For context, Requestable is an enum, and an instance is referenced in the tableView(_:cellForRowAt:) code, and Account is a struct referenced in there as well. According to a couple users they get to the screen referenced here, see the tableView for a second, and then the app crashes.

Crashed: com.apple.main-thread
0  libswiftCore.dylib             0x30ad78c swift_unknownRetain + 9
1  App Name                       0x3e970d outlined copy of Account? + 3913485
2  App Name                       0x4d4297 outlined copy of Requestable + 4874903
3  App Name                       0x6071d1 TableViewController.tableView(_:cellForRowAt:) (TableViewController.swift:404)
4  App Name                       0x622d49 @objc TableViewController.tableView(_:cellForRowAt:) (<compiler-generated>)
like image 822
creeperspeak Avatar asked Oct 17 '18 16:10

creeperspeak


1 Answers

After much trial and error I was able to solve my own problem.

It turns out this app I work for (code I inherited) had a Struct used to model one of the main objects used in the business, and for some reason the backend team was sending the entire object (not filtered to meet client side needs), and the last iOS developer was parsing and storing every attribute, including many (many, many) extraneous ones. I was able to determine that the amount of memory needing to be allocated just to initialize one of these Structs was so huge that it was causing the app to crash when used on the A6 chip devices. I had noticed that all crashes were on iOS 10.3.3, but the bigger clue was that all crashes were on iPhone 5 and 5c.

By removing 1 unused/unnecessary attribute at a time I was able to find the exact point where the overflow began happening. So I simply audited the object (and other similar cases in the app) and removed all unused variables from the Structs, and ultimately began working with the backend team to continue removing these attributes from JSON payloads being sent to the app to reduce the size of the data traveling around.

like image 154
creeperspeak Avatar answered Nov 13 '22 08:11

creeperspeak