UIKitCore -[UIResponder doesNotRecognizeSelector:] crashes since IOS 15.7

Since iOS 15.7 these crash reports have started appearing:

0   CoreFoundation                0x18043bd1c __exceptionPreprocess + 216 (NSException.m:200)

1   libobjc.A.dylib               0x197c60ee4 objc_exception_throw + 56 (objc-exception.mm:565)

2   CoreFoundation                0x18050c75c -[NSObject(NSObject) doesNotRecognizeSelector:] + 140 (NSObject.m:147)

3   UIKitCore                     0x18359320c -[UIResponder doesNotRecognizeSelector:] + 268 (UIResponder.m:685)

4   CoreFoundation                0x1803d561c forwarding + 1472 (NSForwarding.m:3577)

5   CoreFoundation                0x1803d482c _CF_forwarding_prep_0 + 92

6   CoreFoundation                0x1803d22e8 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 20 (CFNotificationCenter.c:652)

7   CoreFoundation                0x1804678e4 ___CFXRegistrationPost_block_invoke + 48 (CFNotificationCenter.c:173)

8   CoreFoundation                0x18043cc04 _CFXRegistrationPost + 416 (CFNotificationCenter.c:199)

9   CoreFoundation                0x1803e7070 _CFXNotificationPost + 708 (CFNotificationCenter.c:1147)

10  Foundation                    0x181ad704c -[NSNotificationCenter postNotificationName:object:userInfo:] + 92 (NSNotification.m:560)

11  UIKitCore                     0x182a9ac08 -[UIScene _invalidate] + 664 (UIScene.m:942)

12  UIKitCore                     0x182c2765c -[UIWindowScene _invalidate] + 160 (UIWindowScene.m:334)

13  UIKitCore                     0x182991f34 -[UIApplication workspace:willDestroyScene:withTransitionContext:completion:] + 216 (UIApplication.m:3999)

14  UIKitCore                     0x1829291a0 -[UIApplicationSceneClientAgent scene:willInvalidateWithEvent:completion:] + 360 (UIApplicationSceneClientAgent.m:61)

15  FrontBoardServices            0x1915b79d8 -[FBSScene _callOutQueue_agent_willDestroyWithTransitionContext:completion:] + 256 (FBSScene.m:456)

16  FrontBoardServices            0x1915bf810 __84-[FBSWorkspaceScenesClient _queue_invalidateScene:withTransitionContext:completion:]_block_invoke_2 + 100 (FBSWorkspaceScenesClient.m:622)

17  FrontBoardServices            0x1915a3bdc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232 (FBSWorkspace.m:352)

18  FrontBoardServices            0x1915b5470 __84-[FBSWorkspaceScenesClient _queue_invalidateScene:withTransitionContext:completion:]_block_invoke + 280 (FBSWorkspaceScenesClient.m:621)

19  libdispatch.dylib             0x1800fc094 _dispatch_client_callout + 16 (object.m:560)

20  libdispatch.dylib             0x18009f150 _dispatch_block_invoke_direct$VARIANT$mp + 220 (queue.c:501)

21  FrontBoardServices            0x1915a52ac FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 40 (FBSSerialQueue.m:157)

22  FrontBoardServices            0x1915a47c0 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176 (FBSSerialQueue.m:181)

23  FrontBoardServices            0x1915a8960 -[FBSSerialQueue _performNextFromRunLoopSource] + 24 (FBSSerialQueue.m:194)

24  CoreFoundation                0x18045c4fc CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24 (CFRunLoop.c:1972)

Looks like all system code. Anyone else running into these since iOS 15.7?

This looks like the method you've used to observe the UISceneDidDisconnectNotification notification is not valid and therefore hitting a doesNotRecognizeSelector: for when the notification is broadcast and the NSNotification tries to notify your observer.

Thanks a lot for your reply.

I don't have any code that listens for the UISceneDidDisconnectNotification though.

I just tried manually posting a UISceneDidDisconnectNotification just to be sure,

 UIWindowScene *windowScene = self.view.window.windowScene;
[[NSNotificationCenter defaultCenter]postNotificationName:UISceneDidDisconnectNotification object:windowScene userInfo:nil];

Didn't cause anything to happen

I also have the same issue on iOS15.7. I don't know the cause, but the number of crash reports is increasing. Did adding it to UISceneDidDisconnectNotification not reduce the number of crashes?

I also have the same issue on iOS15.7. I don't know the cause, but the number of crash reports is increasing. Did adding it to UISceneDidDisconnectNotification not reduce the number of crashes?

Ya, the crashes have been piling up since iOS 15.7, even on older builds that were fine before and I released well before iOS 15.7. I don't know what you mean by "Adding it to UISceneDidDisconnectNotification"?

Taking a look into this a bit deeper I discovered the four following objects listen to UISceneDidDisconnectNotification (three are private API).

  • UIScreen
  • UIEventEnvironment
  • _UIRemoteKeyboards
  • _UIObjectPerCanvas

Hi,

I mean the code you posted.

UIWindowScene *windowScene = self.view.window.windowScene;
[[NSNotificationCenter defaultCenter]postNotificationName:UISceneDidDisconnectNotification object:windowScene userInfo:nil];

I wanted to know if there was a reduction in crashes with that change.

I'm having the same crash as you on iOS 15.7 only. I just submitted the crash-fixed version for review and am waiting for the review to be completed. In my multiple apps, there are apps that crash on iOS15.7 and apps that do not crash. I found the difference and took countermeasures.

I just manually posted the notification to try to tease out the issue per @andyl_'s suggestion that I had registered an observer for UISceneDidDisconnectNotification with an invalid selector...so I manually tried posting the notification to trigger the crash (but as a mentioned, I do not have any code that listens for this notification).

All observers of UISceneDidDisconnectNotification are owned by the system.

 I just submitted the crash-fixed version for review and am waiting for the review to be completed. In my multiple apps, there are apps that crash on iOS15.7 and apps that do not crash. I found the difference and took countermeasures.

Can you share your solution? I can't reproduce the crash in my test environment at all. It probably doesn't help that Apple didn't ship iOS 15.7 SDK simulator runtime to developers.

No, I can't reproduce the crash when testing on a real iOS 15.7 device. I just compared the number of crashes on the report and compared the differences in the code of both apps. We'll see how it goes for a few days and if the number of crashes goes down, I'll share it here. I think that even if I don't know if there is any result, I will confuse a lot of people who are in trouble if I list the changes here. Oddly none of the users reported crashing. A silent crash is also possible.

hello. are you still looking here? A few days have passed since I made changes to the app, but after making changes and updating, the number of crash reports for iOS 15.7 has drastically decreased. I don't know if it will reduce your number of crashes as your case is a bit different, but I will share what I have done. The code I added is below.

// MARK: UISceneSession Lifecycle

  func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
  }

  func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
  }
var window: UIWindow?

  func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    let appDelegate = UIApplication.shared.delegate as! AppDelegate
    appDelegate.window = self.window
   
    guard let _ = (scene as? UIWindowScene) else { return }
  }
@available(iOS, introduced: 15.7, obsoleted: 16.0)
@objc extension SKStoreProductViewController {
  func sceneDisconnected(_ arg: AnyObject) { }
  func appWillTerminate() { }
}

   

Hi can you please explain how exactly you implement the 3rd block of code where you say "Code added to class using Storereviewcontroller"? Sorry I'm a bit of a noob and trying to fix the crash as well.

Hi, I did it like this.

class MainViewController: UIViewController {
    //main code
}

@available(iOS, introduced: 15.7, obsoleted: 16.0)
@objc extension SKStoreProductViewController {
  func sceneDisconnected(_ arg: AnyObject) { }
  func appWillTerminate() { }
}

Same issue here, all on devices that run iOS 15.7. Both iOS and iPadOS. I never have so many crashes.

I cannot find any reason why this should happen.

Last Exception Backtrace:
0   CoreFoundation                	0x180436288 __exceptionPreprocess + 220 (NSException.m:200)
1   libobjc.A.dylib               	0x19916a744 objc_exception_throw + 60 (objc-exception.mm:565)
2   CoreFoundation                	0x180513fc0 -[NSObject(NSObject) doesNotRecognizeSelector:] + 144 (NSObject.m:147)
3   UIKitCore                     	0x1837921f0 -[UIResponder doesNotRecognizeSelector:] + 296 (UIResponder.m:685)
4   CoreFoundation                	0x1803cae98 ___forwarding___ + 1764 (NSForwarding.m:3577)
5   CoreFoundation                	0x1803c9f70 _CF_forwarding_prep_0 + 96 (:-1)
6   CoreFoundation                	0x1803c7834 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 (CFNotificationCenter.c:652)
7   CoreFoundation                	0x180463fd4 ___CFXRegistrationPost_block_invoke + 52 (CFNotificationCenter.c:173)
8   CoreFoundation                	0x1804371d0 _CFXRegistrationPost + 456 (CFNotificationCenter.c:199)
9   CoreFoundation                	0x1803dd8ac _CFXNotificationPost + 728 (CFNotificationCenter.c:1147)
10  Foundation                    	0x181bb0734 -[NSNotificationCenter postNotificationName:object:userInfo:] + 96 (NSNotification.m:560)
11  UIKitCore                     	0x182bf6d98 -[UIScene _invalidate] + 668 (UIScene.m:942)
12  UIKitCore                     	0x182d93800 -[UIWindowScene _invalidate] + 164 (UIWindowScene.m:334)
13  UIKitCore                     	0x182ae3ad0 -[UIApplication workspace:willDestroyScene:withTransitionContext:completion:] + 220 (UIApplication.m:3999)
14  UIKitCore                     	0x182a770fc -[UIApplicationSceneClientAgent scene:willInvalidateWithEvent:completion:] + 388 (UIApplicationSceneClientAgent.m:61)
15  FrontBoardServices            	0x192660510 -[FBSScene _callOutQueue_agent_willDestroyWithTransitionContext:completion:] + 284 (FBSScene.m:456)
16  FrontBoardServices            	0x192668c78 __84-[FBSWorkspaceScenesClient _queue_invalidateScene:withTransitionContext:completion:]_block_invoke_2 + 128 (FBSWorkspaceScenesClient.m:622)
17  FrontBoardServices            	0x19264b308 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240 (FBSWorkspace.m:352)
18  FrontBoardServices            	0x19265ddb0 __84-[FBSWorkspaceScenesClient _queue_invalidateScene:withTransitionContext:completion:]_block_invoke + 328 (FBSWorkspaceScenesClient.m:621)
19  libdispatch.dylib             	0x18009da30 _dispatch_client_callout + 20 (object.m:560)
20  libdispatch.dylib             	0x1800a14e0 _dispatch_block_invoke_direct + 264 (queue.c:501)
21  FrontBoardServices            	0x19264cc70 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48 (FBSSerialQueue.m:157)
22  FrontBoardServices            	0x19264c040 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 220 (FBSSerialQueue.m:181)
23  FrontBoardServices            	0x192650700 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:194)
24  CoreFoundation                	0x180458414 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1972)
25  CoreFoundation                	0x1804691a0 __CFRunLoopDoSource0 + 208 (CFRunLoop.c:2016)
26  CoreFoundation                	0x1803a2694 __CFRunLoopDoSources0 + 268 (CFRunLoop.c:2053)
27  CoreFoundation                	0x1803a805c __CFRunLoopRun + 828 (CFRunLoop.c:2951)
28  CoreFoundation                	0x1803bbbc8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
29  GraphicsServices              	0x19c52b374 GSEventRunModal + 164 (GSEvent.c:2200)
30  UIKitCore                     	0x182d31b58 -[UIApplication _run] + 1100 (UIApplication.m:3511)
31  UIKitCore                     	0x182ab3098 UIApplicationMain + 364 (UIApplication.m:5064)
32  Weerbericht                   	0x1049859b4 main + 80 (main.m:7)
33  dyld                          	0x104ff1da4 start + 520 (dyldMain.cpp:879)

UIKitCore -[UIResponder doesNotRecognizeSelector:] crashes since IOS 15.7
 
 
Q