OneSignal-iOS-SDK icon indicating copy to clipboard operation
OneSignal-iOS-SDK copied to clipboard

[Bug]: NSInvalidUnarchiveOperationException *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (OSIndirectNotification) for key (NS.objects) because no class named "OSIndirectNotification" was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target). If the class was renamed, use setClassName:forClass: to add a class translation mapping to NSKeyedUnarchiver

Open marcosnovaesq opened this issue 3 years ago • 26 comments

What happened?

We updated our react-native-onesignal lib that used OneSignal-iOS-SDK version 2.13.0, which had this bug, according to this issue and according to this one it got solved on later versions. We updated react-native-onesignal to version 4.3.7 ( uses sdk version 3.10.1)and did the correct steps to make it work in ios. Aparrently it started happening to some of our iOS users. Digging in the code we found that it was supossed to run a migration on some version, but aparrently on our end it didn't happen. Anyway our test users that had this happening reinstalled and began to work, but not a fix for common production user

Steps to reproduce?

Could not reproduce in simulator and in production not all of our ios users are having this error

What did you expect to happen?

Work ok for all ios users

OneSignal iOS SDK version

3.10.1

iOS version

15

Specific iOS version

happens in mostly iOS 15.x versions

Relevant log output

CoreFoundation +0x099d78 __exceptionPreprocess libobjc.A +0x016730 objc_exception_throw Foundation +0x1208bc -[NSCoder __failWithException:] Foundation +0x120a28 -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] Foundation +0x03650c _decodeObjectBinary Foundation +0x07da74 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] Foundation +0x095578 -[NSArray(NSArray) initWithCoder:] Foundation +0x036cac _decodeObjectBinary Foundation +0x01bbb8 _decodeObject Foundation +0x03ad88 -[NSKeyedUnarchiver decodeObjectForKey:] Foundation +0x09e8bc +[NSKeyedUnarchiver unarchiveObjectWithData:] OneSignal +0x054f74 finishProcessingNotification OneSignal +0x04c7a4 finishProcessingNotification OneSignal +0x041fd8 finishProcessingNotification OneSignal +0x024d28 onesignal_Log OneSignal +0x05ee1c finishProcessingNotification OneSignal +0x010fb4 onesignal_Log libdispatch +0x001e64 _dispatch_call_block_and_release libdispatch +0x003a28 _dispatch_client_callout libdispatch +0x011f44 _dispatch_main_queue_drain libdispatch +0x011b94 _dispatch_main_queue_callback_4CF CoreFoundation +0x0522ec CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE CoreFoundation +0x00c1f0 __CFRunLoopRun CoreFoundation +0x01f6b4 CFRunLoopRunSpecific GraphicsServices +0x001370 GSEventRunModal UIKitCore +0x513e84 -[UIApplication _run] UIKitCore +0x2955e8 UIApplicationMain myapp +0x008120 0x1038c5ce4

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

marcosnovaesq avatar May 27 '22 19:05 marcosnovaesq

i'm having crash with a lot of users on production, can someone help me?

marcosnovaesq avatar May 30 '22 21:05 marcosnovaesq

@marcosnovaesq Thanks for reporting, does this issue happen only if you upgrade the app in place? In other words does this crash still happen if you uninstall and reinstall the app?

jkasten2 avatar May 31 '22 18:05 jkasten2

@jkasten2 yes, when users reinstall the app it start working again as supposed to... Any info i could pass you to repro? We are with this bug for 2 weeks already

marcosnovaesq avatar May 31 '22 18:05 marcosnovaesq

according to method migrateToVersion_02_14_00_AndGreater in class OSMigrationController.m if the user had a cached sdk version lower than 21400 then it should migrate... Before the major update we did we had onesignal-ios-sdk on version 21301. Maye it's the cause, i just don't know why users aren't getting migrated...

marcosnovaesq avatar May 31 '22 20:05 marcosnovaesq

+1

I'm having this exact issue. Recently updated from 3.7.3 to 4.3.7 and some iOS users randomly crash with

-[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (OSIndirectNotification) for key (NS.objects) because no class named "OSIndirectNotification" was found

Asking for a complete reinstall solves the issue, but that's not a valid solution to the entire user base.

Unfortunately, we haven't been able to reproduce the issue on the simulator either.

pedrosbmartins avatar May 31 '22 20:05 pedrosbmartins

any updates on this? I managed to get a lastExceptionBackTrace from ips files

"lastExceptionBacktrace" : [
    {"imageOffset":630136,"symbol":"__exceptionPreprocess","symbolLocation":220,"imageIndex":6},
    {"imageOffset":91956,"symbol":"objc_exception_throw","symbolLocation":60,"imageIndex":4},
    {"imageOffset":1181888,"symbol":"-[NSCoder __failWithException:]","symbolLocation":180,"imageIndex":11},
    {"imageOffset":1182252,"symbol":"-[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:]","symbolLocation":260,"imageIndex":11},
    {"imageOffset":222480,"symbol":"_decodeObjectBinary","symbolLocation":588,"imageIndex":11},
    {"imageOffset":514680,"symbol":"-[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]","symbolLocation":1404,"imageIndex":11},
    {"imageOffset":611708,"symbol":"-[NSArray(NSArray) initWithCoder:]","symbolLocation":176,"imageIndex":11},
    {"imageOffset":224432,"symbol":"_decodeObjectBinary","symbolLocation":2540,"imageIndex":11},
    {"imageOffset":113596,"symbol":"_decodeObject","symbolLocation":184,"imageIndex":11},
    {"imageOffset":241036,"symbol":"-[NSKeyedUnarchiver decodeObjectForKey:]","symbolLocation":176,"imageIndex":11},
    {"imageOffset":649408,"symbol":"+[NSKeyedUnarchiver unarchiveObjectWithData:]","symbolLocation":84,"imageIndex":11},
    {"imageOffset":348020,"imageIndex":17},
    {"imageOffset":313252,"imageIndex":17},
    {"imageOffset":270296,"imageIndex":17},
    {"imageOffset":150824,"imageIndex":17},
    {"imageOffset":388636,"imageIndex":17},
    {"imageOffset":69556,"imageIndex":17},
    {"imageOffset":7784,"symbol":"_dispatch_call_block_and_release","symbolLocation":32,"imageIndex":5},
    {"imageOffset":14892,"symbol":"_dispatch_client_callout","symbolLocation":20,"imageIndex":5},
    {"imageOffset":73544,"symbol":"_dispatch_main_queue_drain","symbolLocation":928,"imageIndex":5},
    {"imageOffset":72600,"symbol":"_dispatch_main_queue_callback_4CF","symbolLocation":44,"imageIndex":5},
    {"imageOffset":336624,"symbol":"__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__","symbolLocation":16,"imageIndex":6},
    {"imageOffset":49652,"symbol":"__CFRunLoopRun","symbolLocation":2532,"imageIndex":6},
    {"imageOffset":128696,"symbol":"CFRunLoopRunSpecific","symbolLocation":600,"imageIndex":6},
    {"imageOffset":4980,"symbol":"GSEventRunModal","symbolLocation":164,"imageIndex":7},
    {"imageOffset":5324424,"symbol":"-[UIApplication _run]","symbolLocation":1100,"imageIndex":8},
    {"imageOffset":2708972,"symbol":"UIApplicationMain","symbolLocation":364,"imageIndex":8},
    {"imageOffset":33056,"imageIndex":9},
    {"imageOffset":105700,"symbol":"start","symbolLocation":520,"imageIndex":10}
]

marcosnovaesq avatar Jun 01 '22 21:06 marcosnovaesq

any updates on this?

marcosnovaesq avatar Jun 04 '22 15:06 marcosnovaesq

Updated: we released a version with the one signal completely removed from the app and the user stopped seeing the crash. We then released another version with it and started crashing again. So i don't know if you plan to fix this issue again or not, but for the moment we are going without one signal plugged in our app

marcosnovaesq avatar Jun 08 '22 14:06 marcosnovaesq

@marcosnovaesq I apologize for the inconvenience we are actively working in reproducing and fixing this issue

emawby avatar Jun 09 '22 16:06 emawby

@emawby hi, no problem, i tried downgrading sdk for version 2.14.2, problem is i have only one user that i can use to reproduce.. So it went as following: purged one signal -> worked no crash introduced new version with one signal as if the purge never happened -> started happening again dowgraded sdk version to 2.14.2 -> apparently worked with no crash ( it's the version that supposedly fixed the crash ) released a version with the major version 3.10.1 again -> apparently no crash at the moment If there's anything i can help you with, just reach me out

marcosnovaesq avatar Jun 09 '22 17:06 marcosnovaesq

@marcosnovaesq @pedrosbmartins After researching the issue I confirmed a case where this issue could happen, if you updated the OneSignal SDK on the main target but left your OneSignalNotificationServiceExtension target on an older version.

Can you check your Podfile to ensure it has the following?:

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.4.3', '< 4.0'
end

Source: Step-by-Step React Native 3.x to 4.0.0 Upgrade Guide - Step 2

Make sure to remove pod 'OneSignal' as well. Lastly run pod install before building in Xcode, so the Podfile changes take effect.

jkasten2 avatar Jun 14 '22 23:06 jkasten2

@jkasten2 On my side, when we upgraded to another major, we did not change this line, at first. When I was fixing the bug, changing this line was one of my many failed attempts xD... But we didn't change this line when we upgraded, only later. I only managed to fix when i released a version with react-native-onesignal 3.8.1

marcosnovaesq avatar Jun 17 '22 14:06 marcosnovaesq

@marcosnovaesq Thanks for following up, however I am not sure I understand. Sounds like you ran into some issue upgrading that line in your Podfile but got it updated in the end?

Now that everything is updated you are no longer seeing this issue now?

jkasten2 avatar Jun 17 '22 21:06 jkasten2

Sorry for the confusion, what happened was -> updated one signal from 3.x.x to 4.x.x and that line was not changed -> issue started happening in production -> first attempt to solve it was to change this line as it was the only difference from the update guide of your documentation https://documentation.onesignal.com/docs/step-by-step-react-native-3x-to-400-upgrade-guide

-> issue still happening, crash still being caught by sentry

marcosnovaesq avatar Jun 17 '22 21:06 marcosnovaesq

@marcosnovaesq I see, that is clear to me now!

My best guess what is happening now is that the migration was already run but the old OneSignal version in the NSE (NotificationServiceExtension) added some records with the old version. Now that the NSE is updated it isn't writing the old format, however now there are some stuck old records continuing to create this crash.

We will look into what can be done to address this state your app and possibly some others are stuck in due to this mix of OneSignal versions.

jkasten2 avatar Jun 17 '22 21:06 jkasten2

thanks @jkasten2 i thought it weird too, looked at the code and the migration should have run, maybe it just didn't migrate correctly? Maybe a edge case where you migrate to buggy 3.x.x to major 4, i don't know. Are you planning on release something to address it? Thanks!!

marcosnovaesq avatar Jun 21 '22 17:06 marcosnovaesq

@marcosnovaesq I believe your user got migrated correct on the first time the app ran to upgrade them. But the issue is the old NSE put some old record on the device and the migration won't run a 2nd time currently to fix those records. We are looking into addressing this edge case in the next release (3.11.3 or 3.12.0).

jkasten2 avatar Jun 21 '22 18:06 jkasten2

Oh i see! it makes sense since that line was not updated together, it used old NSE... nice

marcosnovaesq avatar Jun 21 '22 18:06 marcosnovaesq

Hello @jkasten2 how is it going? any news? Thanks

marcosnovaesq avatar Jul 11 '22 22:07 marcosnovaesq

@marcosnovaesq Sorry for the delay, we don't have an eta yet on this fix.

jkasten2 avatar Jul 12 '22 18:07 jkasten2

Hi @jkasten2 Please, let us know if you get any updates on this issue.

Thanks

Ariandr avatar Jul 13 '22 11:07 Ariandr

Hi our existing iOS app user get this error as well, even updating app to latest OneSginal SDK version didn't help, when is this issue getting fixed?

angyy10 avatar Jul 31 '22 14:07 angyy10

@angyy10 according to our interpretation we should only wait for them to release a fix for this... But no estimates so far, let me know if you fix this

marcosnovaesq avatar Aug 03 '22 15:08 marcosnovaesq

Any news?

marcosnovaesq avatar Aug 15 '22 14:08 marcosnovaesq

Hello, are you still looking into this?

marcosnovaesq avatar Sep 06 '22 16:09 marcosnovaesq

Hello, anyone looking into this can provide more information regarding the current situation?

marcosnovaesq avatar Dec 20 '22 15:12 marcosnovaesq