OneSignal / OneSignal-iOS-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native iOS app with OneSignal. https://onesignal.com
Other
496 stars 263 forks source link

[Bug]: OneSignalUserDefaults Crash #1365

Closed danhalliday closed 6 months ago

danhalliday commented 9 months ago

What happened?

iOS app crashed in production with a stack trace showing OneSignal frames.

Steps to reproduce?

No idea. This is a remote crash report from Crashlytics.

What did you expect to happen?

The library should not cause a crash, regardless of what I may be doing wrong in using it.

OneSignal iOS SDK version

5.1.0

iOS version

11 or below

Specific iOS version

* 17.2.1

Relevant log output

Crashed: com.apple.NSURLSession-delegate
0  CoreFoundation                 0x11d18 __CFBasicHashRehash + 112
1  CoreFoundation                 0x119a8 __CFBasicHashAddValue + 100
2  CoreFoundation                 0x1190c CFBasicHashAddValue + 420
3  CoreFoundation                 0x116fc CFDictionaryAddValue + 208
4  CoreFoundation                 0x10c34 _flattenPlist + 308
5  CoreFoundation                 0x10d98 _flattenPlist + 664
6  CoreFoundation                 0x10dfc _flattenPlist + 764
7  CoreFoundation                 0x10d98 _flattenPlist + 664
8  CoreFoundation                 0x107dc __CFBinaryPlistWriteOrPresize + 240
9  Foundation                     0x3c658 -[NSKeyedArchiver finishEncoding] + 640
10 Foundation                     0x6e7714 +[NSKeyedArchiver archivedDataWithRootObject:] + 112
11 OneSignalCore                  0x112b4 -[OneSignalUserDefaults saveCodeableDataForKey:withValue:] + 88
12 OneSignalUser                  0x1c264 block_destroy_helper.32 + 23276
13 OneSignalUser                  0x33970 __swift_noop_void_return + 9644
14 OneSignalCore                  0xdcb4 -[OneSignalClient handleJSONNSURLResponse:data:error:isAsync:withRequest:onSuccess:onFailure:] + 848
15 OneSignalCore                  0xc998 __54-[OneSignalClient executeRequest:onSuccess:onFailure:]_block_invoke + 44
16 CFNetwork                      0xf368 _CFNetworkSetHSTSStoragePath + 28508
17 CFNetwork                      0x2d218 CFHTTPMessageCopySerializedMessage + 13784
18 libdispatch.dylib              0x26a8 _dispatch_call_block_and_release + 32
19 libdispatch.dylib              0x4300 _dispatch_client_callout + 20
20 libdispatch.dylib              0xb894 _dispatch_lane_serial_drain + 748
21 libdispatch.dylib              0xc3f8 _dispatch_lane_invoke + 432
22 libdispatch.dylib              0x17004 _dispatch_root_queue_drain_deferred_wlh + 288
23 libdispatch.dylib              0x16878 _dispatch_workloop_worker_thread + 404
24 libsystem_pthread.dylib        0x1964 _pthread_wqthread + 288
25 libsystem_pthread.dylib        0x1a04 start_wqthread + 8

Code of Conduct

danhalliday commented 8 months ago

@nan-li FYI this is not fixed in 5.1.3.

ihijazi commented 7 months ago

I'm having the same issue. I've posted also about another issue which might be relevant but still no updated on it: https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/858

One thing I noted is the crash happens when not using cellular data (i.e not WiFi)

kunalzigma commented 7 months ago

@danhalliday am seeing this crash, first time on 5.1.3. Updated app on 30th march, saw this same day. How many crashes can we expect ? like out of 100 or 1000 sessions?

danhalliday commented 7 months ago

We are seeing in the ballpark of 0.1% of sessions produce something like this bug (we have several different traces though which I think are ultimately this same one). Naturally whether that’s a problem will depend on the size of your user base. But FWIW this is currently our biggest crasher.

dombartenope commented 7 months ago

Hi folks,

Thank you all for your reports here. I am creating an internal ticket to highlight the issue you're all facing here directly with the SDK team. I'll be linking them this thread, so the team can reply or request information as needed.

Thanks Dom OS Technical Support

yasht01 commented 6 months ago

Hey folks, Saw this error for the first time on our app using Flutter SDK. Is there any extra info that we can provide to help debug this issue better?

Onesignal Flutter SDK version: 5.1.0

nan-li commented 6 months ago

Hi everyone, thank you for your reports,

We have made a few crash fixes since. Please update to Release 5.1.6 or later, and let us know if the crashes are resolved, or what crashes still remain.

danhalliday commented 5 months ago

Hi @nan-li, it doesn’t look like this is fixed in 5.1.6. I have a new release out to a few thousand users and am still seeing frequent crashes with the following trace.

Crashed: OneSignal.OSPropertyOperationExecutor
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
0  CoreFoundation                 0x13054 _CFArrayReplaceValues + 1004
1  CoreFoundation                 0x128d8 CFArrayAppendValue + 152
2  CoreFoundation                 0x11068 _flattenPlist + 292
3  CoreFoundation                 0x11248 _flattenPlist + 772
4  CoreFoundation                 0x111e4 _flattenPlist + 672
5  CoreFoundation                 0x10c2c __CFBinaryPlistWriteOrPresize + 240
6  Foundation                     0x39230 -[NSKeyedArchiver finishEncoding] + 640
7  Foundation                     0x6f12a8 +[NSKeyedArchiver archivedDataWithRootObject:] + 112
8  OneSignalCore                  0xd69c -[OneSignalUserDefaults saveCodeableDataForKey:withValue:] + 88
9  OneSignalUser                  0x1f75c block_destroy_helper.32 + 27880
10 OneSignalUser                  0x1e0bc block_destroy_helper.32 + 22088
11 libdispatch.dylib              0x213c _dispatch_call_block_and_release + 32
12 libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
13 libdispatch.dylib              0xb400 _dispatch_lane_serial_drain + 748
14 libdispatch.dylib              0xbf30 _dispatch_lane_invoke + 380
15 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh + 288
16 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread + 404
17 libsystem_pthread.dylib        0x1f20 _pthread_wqthread + 288
18 libsystem_pthread.dylib        0x1fc0 start_wqthread + 8

My new release also has a lower-frequency crash with a similar trace, more similar to the original one I posted above:

Crashed: OneSignal.OSPropertyOperationExecutor
EXC_BREAKPOINT 0x000000019df30168
0  CoreFoundation                 0x12168 __CFBasicHashRehash + 112
1  CoreFoundation                 0x11df8 __CFBasicHashAddValue + 100
2  CoreFoundation                 0x11d5c CFBasicHashAddValue + 420
3  CoreFoundation                 0x11b4c CFDictionaryAddValue + 208
4  CoreFoundation                 0x11078 _flattenPlist + 308
5  CoreFoundation                 0x11248 _flattenPlist + 772
6  CoreFoundation                 0x111e4 _flattenPlist + 672
7  CoreFoundation                 0x10c2c __CFBinaryPlistWriteOrPresize + 240
8  Foundation                     0x39230 -[NSKeyedArchiver finishEncoding] + 640
9  Foundation                     0x6f12a8 +[NSKeyedArchiver archivedDataWithRootObject:] + 112
10 OneSignalCore                  0xd69c -[OneSignalUserDefaults saveCodeableDataForKey:withValue:] + 88
11 OneSignalUser                  0x1ebf8 block_destroy_helper.32 + 24964
12 OneSignalUser                  0x1e0bc block_destroy_helper.32 + 22088
13 libdispatch.dylib              0x213c _dispatch_call_block_and_release + 32
14 libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
15 libdispatch.dylib              0xb400 _dispatch_lane_serial_drain + 748
16 libdispatch.dylib              0xbf30 _dispatch_lane_invoke + 380
17 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh + 288
18 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread + 404
19 libsystem_pthread.dylib        0x1f20 _pthread_wqthread + 288
20 libsystem_pthread.dylib        0x1fc0 start_wqthread + 8
danhalliday commented 5 months ago

Also another variant, in case this is of any use...

Crashed: OneSignal.OSPropertyOperationExecutor
EXC_BREAKPOINT 0x000000019df30168
0  CoreFoundation                 0x12168 __CFBasicHashRehash + 112
1  CoreFoundation                 0x11df8 __CFBasicHashAddValue + 100
2  CoreFoundation                 0x30a0 CFDictionarySetValue + 208
3  Foundation                     0x21534 _encodeObject + 660
4  Foundation                     0x210dc -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] + 460
5  Foundation                     0x200c4 -[NSDictionary(NSDictionary) encodeWithCoder:] + 572
6  Foundation                     0x2173c _encodeObject + 1180
7  OneSignalUser                  0xf1f4 block_destroy_helper + 6436
8  OneSignalUser                  0xf3ac block_destroy_helper + 6876
9  Foundation                     0x2173c _encodeObject + 1180
10 Foundation                     0x210dc -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] + 460
11 Foundation                     0x4ffc0 -[NSArray(NSArray) encodeWithCoder:] + 588
12 Foundation                     0x2173c _encodeObject + 1180
13 Foundation                     0x6f12a0 +[NSKeyedArchiver archivedDataWithRootObject:] + 104
14 OneSignalCore                  0xd69c -[OneSignalUserDefaults saveCodeableDataForKey:withValue:] + 88
15 OneSignalUser                  0x1ebf8 block_destroy_helper.32 + 24964
16 OneSignalUser                  0x1e0bc block_destroy_helper.32 + 22088
17 libdispatch.dylib              0x213c _dispatch_call_block_and_release + 32
18 libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
19 libdispatch.dylib              0xb400 _dispatch_lane_serial_drain + 748
20 libdispatch.dylib              0xbf30 _dispatch_lane_invoke + 380
21 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh + 288
22 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread + 404
23 libsystem_pthread.dylib        0x1f20 _pthread_wqthread + 288
24 libsystem_pthread.dylib        0x1fc0 start_wqthread + 8
nan-li commented 5 months ago

Hi @danhalliday thank you for following up with these 3 stacktraces.

nan-li commented 5 months ago

Hi @danhalliday I am not sure how these crashes could be happening, so I am still investigating.

Any additional information you can share will be helpful:

  1. Do you have updated data on frequency of these crash reports?
  2. Do you have data if the app is in the background or foreground?
  3. Do you have information about the memory usage or state of the memory at time of the crash? One possibility I am considering is the app being out of memory at the time we are saving information. Particularly if you know that there is high memory usage in the app already.