Reputation: 10159
I am getting constant and seemingly random crashes in my NotificationService app extension. This is my first app extension so I'm not sure how debugging normally works, but my exceptions breakpoint is not getting triggered. The extension just exits and the default notification goes through. I've been able to track down specific spots where the extension crashes using line breakpoints and simply stepping through until it crashes. The odd thing is that it will consistently crash on the same exact line every time (so it doesn't seem to be a memory pressure issue). I can't find any ryhm or reason behind any of this. Here are a few examples of crashes:
for key in dict.keys {}
but not for (key, _) in dict {}
.dateFormatter.date(from:)
but not just dateFormatter
.attributes.count
where attributes is a custom struct.existingObjects.insert(newObject, at: 0)
but not existingObjects.append(newObject)
I haven't seen the crash on my iPhone 6, but my iPad Air 2, iPhone 6s Plus and iPhone 7 all consistently crash on the same line until I make a change, which moves the crash to a new point in the code.
Upvotes: 1
Views: 3689
Reputation: 10159
After quit a bit of research I finally stumbled onto the answer: https://forums.developer.apple.com/thread/60632.
It is indeed an out of memory error. I was seeing only 5mb in Xcode instruments and thought it couldn't possibly killing the process for so little memory, but NotificationService extensions have a very low memory limit and the frameworks I was linking against started the process out at around 4mb. It was just a matter of time before something tipped the scales.
Upvotes: 3