Onesignal-ios-sdk: In-App Message Throws Unrecognized selector sent to instance

Created on 21 Mar 2020  ·  7Comments  ·  Source: OneSignal/OneSignal-iOS-SDK

Description:
Interacting with In-App messages crashes the APP, and throws an NSInvalidArgumentExceptionand unrecognized selector sent to instance

Environment

  1. SDK Version - 2.12.6
  2. Added via Carthage
  3. iOS Test Device OS Version: 13.3.1
  4. Xcode Version: 11.3.1

Steps to Reproduce Issue:

  1. Create In-App message on admin dashboard
  2. Send to test device
  3. Interact with in-app Modal (Close or Tap on the button or any action on the modal)
  4. App crashes. (This crash happens as long as the modal is dismissed.)

Anything else:

2020-03-21 02:14:57.951217+0100 Company_Name[9991:4859954] [Process] kill() returned unexpected error 1
2020-03-21 02:14:57.951545+0100 Company_Name[9991:4859954] [Process] kill() returned unexpected error 1
2020-03-21 02:14:58.019012+0100 Company_Name[9991:4859954] [Process] kill() returned unexpected error 1
2020-03-21 02:14:58.258264+0100 Company_Name[9991:4859954] -[GUL_Company_Name.AppDelegate-7BB01BA2-6443-4126-A781-C90DDB3156C8 window]: unrecognized selector sent to instance 0x2825247a0
2020-03-21 02:14:58.276780+0100 Company_Name[9991:4859954] Exception name=NSInvalidArgumentException, reason=-[GUL_Company_Name.AppDelegate-7BB01BA2-6443-4126-A781-C90DDB3156C8 window]: unrecognized selector sent to instance 0x2825247a0, userInfo=(null) addresses=(0x190356a48 0x19007dfa4 0x19025a5a8 0x19440a4e8 0x19035a86c 0x19035ca7c 0x1067aa940 0x1067cb918 0x194865d90 0x194839c70 0x19483a178 0x196debdac 0x106c4ebd8 0x106c5cc34 0x1902d45e4 0x1902cf5d8 0x1902ceadc 0x19a26f328 0x1943dc63c 0x100fc5aa4 0x190158360) symbols=(
    0   CoreFoundation                      0x0000000190356a5c 7519E999-1053-3367-B9D5-8844F6D3BDC6 + 1227356
    1   libobjc.A.dylib                     0x000000019007dfa4 objc_exception_throw + 56
    2   CoreFoundation                      0x000000019025a5a8 7519E999-1053-3367-B9D5-8844F6D3BDC6 + 193960
    3   UIKitCore                           0x000000019440a4e8 D7630067-7A00-3CB7-99E1-E7F6C55D85C5 + 10687720
    4   CoreFoundation                      0x000000019035a86c 7519E999-1053-3367-B9D5-8844F6D3BDC6 + 1243244
    5   CoreFoundation                      0x000000019035ca7c _CF_forwarding_prep_0 + 92
    6   OneSignal                           0x00000001067aa940 -[OSMessagingController messageViewControllerWasDismissed] + 804
    7   OneSignal                           0x00000001067cb918 __72-[OSInAppMessageViewController dismissCurrentInAppMessage:withVelocity:]_block_invoke.259 + 104
    8   UIKitCore                           0x0000000194865d90 D7630067-7A00-3CB7-99E1-E7F6C55D85C5 + 15256976
    9   UIKitCore                           0x0000000194839c70 D7630067-7A00-3CB7-99E1-E7F6C55D85C5 + 15076464
    10  UIKitCore                           0x000000019483a178 D7630067-7A00-3CB7-99E1-E7F6C55D85C5 + 15077752
    11  QuartzCore                          0x0000000196debdac 3EE40592-F011-38CC-8472-776B3C912A42 + 1453484
    12  libdispatch.dylib                   0x0000000106c4ebd8 _dispatch_client_callout + 16
    13  libdispatch.dylib                   0x0000000106c5cc34 _dispatch_main_queue_callback_4CF + 1316
    14  CoreFoundation                      0x00000001902d45e4 7519E999-1053-3367-B9D5-8844F6D3BDC6 + 693732
    15  CoreFoundation                      0x00000001902cf5d8 7519E999-1053-3367-B9D5-8844F6D3BDC6 + 673240
    16  CoreFoundation                      0x00000001902ceadc CFRunLoopRunSpecific + 464
    17  GraphicsServices                    0x000000019a26f328 GSEventRunModal + 104
    18  UIKitCore                           0x00000001943dc63c UIApplicationMain + 1936
    19  Company_Name                            0x0000000100fc5aa4 main + 124
    20  libdyld.dylib                       0x0000000190158360 7B531A15-3E73-3185-90E2-B88D9476DA5E + 4960
)
2020-03-21 02:14:58.277771+0100 Company_Name[9991:4859954] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GUL_Company_Name.AppDelegate-7BB01BA2-6443-4126-A781-C90DDB3156C8 window]: unrecognized selector sent to instance 0x2825247a0'
*** First throw call stack:
(0x190356a48 0x19007dfa4 0x19025a5a8 0x19440a4e8 0x19035a86c 0x19035ca7c 0x1067aa940 0x1067cb918 0x194865d90 0x194839c70 0x19483a178 0x196debdac 0x106c4ebd8 0x106c5cc34 0x1902d45e4 0x1902cf5d8 0x1902ceadc 0x19a26f328 0x1943dc63c 0x100fc5aa4 0x190158360)
libc++abi.dylib: terminating with uncaught exception of type NSException

Crash Breakpoint
Screenshot 2020-03-21 at 02 29 48

Screenshot 2020-03-21 at 02 30 08

Medium Priority

All 7 comments

The crash seems to point that window is nil on your UIApplicationDelegate. Are you overriding this by chance? Or any other code that could be modify window at runtime?

The screenshot doesn't seems to line up with your stacktrace, it my just be background thread that happened to be running at the time of the crash.

Is the crash consistent or it only happen sometimes after closing an in app?

Can you try printing this in a few spots in your app to see if it becomes nil at anytime?

[[[UIApplication sharedApplication] delegate] window];

@jkasten2 That's always null in the application.

Window Check:
print("Window Nil Check: ", UIApplication.shared.delegate?.window == nil)

Log:
Window Nil Check:  true

@tonespy We fixed the issue in the PR above. The fix will be included in the next release. Thanks for helping us hunt down this issue!

@tonespy This is now part of the 2.13.1 release

Hi Team,

We are getting same issue in Xamarin.iOS SDK latest - 3.8.1
Is this fix incorporated into Xamarin.iOS SDK?

That's the correct version but a new version 3.8.2 was released recently. Please give that one a try as well and double-check that the plugin updated correctly. @rspltestall.

Closing due to no response

Was this page helpful?
0 / 5 - 0 ratings

Related issues

halilyuce picture halilyuce  ·  3Comments

ldco2016 picture ldco2016  ·  3Comments

konkontos picture konkontos  ·  3Comments

luai-kalkatawi picture luai-kalkatawi  ·  4Comments

0x7fs picture 0x7fs  ·  6Comments