iOS15 nextResponder NOT being set to nil cause App Crash

Viewed 118

Our App runs fine in iOS14 but crashing in iOS15

The next responder for the contentViewController in ModalVC is the ModalVC. The deallocation of the modal happens before the contentVC in both iOS14 and 15, meaning that the nextResponder of the contentVC is dealloc'ed before contentVC.

2021-09-02 09:26:56.008505-0700 AppDevelopment[75463:1003950] ----------- ModalVC dealloc
2021-09-02 09:29:02.799891-0700 AppDevelopment[75463:1003950] ----------- NewPhotoAssetVC dealloc 

In our repro case, NewPhotoAssetViewController is the contentVC for a modal. In NewPhotoAssetViewController 's dealloc method if I ask for the nextResponder in iOS14, this is what I get:

(lldb) po [self nextResponder]
 nil 

However, on iOS15 if I ask for the next responder in the same place I get:

(lldb) po [self nextResponder]
 2021-09-02 09:27:10.952742-0700 AppDevelopment[75463:1003950] *** -[ModalViewController retain]: message sent to deallocated instance 0x7fae0d6815b0
 error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). 

The process has been returned to the state before expression evaluation. It appears that for some reason the nextResponder for the contentVC is NOT being set to nil in iOS15. We are then seeing crashes as we message this garbage pointer that may have changed into any other object.

nextResponder is readonly, so we can't explicitly set it to nil. Not sure if this is an Apple bug, is there a way to get around this?

0 Answers
Related