adaptyteam / AdaptySDK-Flutter

SDK for growing mobile in-app purchases
https://docs.adapty.io/docs/quickstart
MIT License
95 stars 17 forks source link

iOS App Crashes After Push Notification Permission #53

Closed ibrahimdevs closed 2 years ago

ibrahimdevs commented 2 years ago

Hi,

Because of plugin's swizzling mechanism I'm getting crash error. I'm asking push notification permission request. When user click "Allow" for push permission, my app is crashing randomly, not every time. I'm getting this error on iOS devices.

My flutter version 3.0.5 and dart 2.17.6. I'm using adapty_flutter 1.0.12 and onesignal_flutter 3.3.2. This error comes from one of them but I'm not sure which one.

Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_PROTECTION_FAILURE 0x000000016f513fd0

Crashed: com.apple.main-thread 0 libicucore.A.dylib 0xb3938 icu::UnicodeString::copyFrom(icu::UnicodeString const&, signed char) + 4 1 libicucore.A.dylib 0x17e200 icu::number::LocalizedNumberFormatter::getDecimalFormatSymbols() const + 956 2 libicucore.A.dylib 0x18c2ec icu::number::impl::ImmutablePatternModifier::processQuantity(icu::number::impl::DecimalQuantity&, icu::number::impl::MicroProps&, UErrorCode&) const + 76 3 libicucore.A.dylib 0x17ed04 icu::number::LocalizedNumberFormatter::getDecimalFormatSymbols() const + 3776 4 libicucore.A.dylib 0x17ebf4 icu::number::LocalizedNumberFormatter::getDecimalFormatSymbols() const + 3504 5 libicucore.A.dylib 0x17d84c icu::number::LocalizedNumberFormatter::formatImpl(icu::number::impl::UFormattedNumberData, UErrorCode&) const + 112 6 libicucore.A.dylib 0x1ed1c0 icu::SimpleDateFormat::zeroPaddingNumber(icu::NumberFormat const, icu::UnicodeString&, int, int, int) const + 756 7 libicucore.A.dylib 0x1eb8c4 icu::SimpleDateFormat::subFormat(icu::UnicodeString&, char16_t, int, UDisplayContext, int, char16_t, icu::FieldPositionHandler&, icu::Calendar&, UErrorCode&) const + 1668 8 libicucore.A.dylib 0x1eb05c icu::SimpleDateFormat::_format(icu::Calendar&, icu::UnicodeString&, icu::FieldPositionHandler&, UErrorCode&) const + 520 9 libicucore.A.dylib 0x1eae34 icu::SimpleDateFormat::format(icu::Calendar&, icu::UnicodeString&, icu::FieldPosition&) const + 84 10 libicucore.A.dylib 0x116770 icu::DateFormat::format(double, icu::UnicodeString&, icu::FieldPosition&) const + 176 11 libicucore.A.dylib 0x220760 udat_format + 352 12 CoreFoundation 0x3ebb8 cficu_udat_format + 68 13 CoreFoundation 0x4ca18 CFDateFormatterCreateStringWithAbsoluteTime + 172 14 CoreFoundation 0xaddec -[NSDate descriptionWithLocale:] + 496 15 Foundation 0x1cb04 _NSDescriptionWithLocaleFunc + 68 16 CoreFoundation 0x9b8c CFStringAppendFormatCore + 11120 17 CoreFoundation 0x2898c _CFStringCreateWithFormatAndArgumentsReturningMetadata + 176 18 Foundation 0x19f30 +[NSString stringWithFormat:] + 76 19 OneSignal 0xfae0 +[OneSignal shouldRegisterUserAfterDelay] + 164 20 OneSignal 0xf974 +[OneSignal registerUser] + 72 21 OneSignal 0xf1a4 +[OneSignal updateDeviceToken:] + 296 22 OneSignal 0x12bf4 +[OneSignal didRegisterForRemoteNotifications:deviceToken:] + 228 23 OneSignal 0x2e744 -[OneSignalAppDelegate oneSignalDidRegisterForRemoteNotifications:deviceToken:] + 136 24 Adapty 0x21848 $s6Adapty19AppDelegateSwizzlerC20swizzled_application33_882DEC7821489E8AC05D52AA1ADD858BLL_48didRegisterForRemoteNotificationsWithDeviceTokenySo13UIApplicationC_10Foundation4DataVtFTf4nnd_n + 180 25 Adapty 0x21720 $s6Adapty19AppDelegateSwizzlerC20swizzled_application33_882DEC7821489E8AC05D52AA1ADD858BLL_48didRegisterForRemoteNotificationsWithDeviceTokenySo13UIApplicationC_10Foundation4DataVtFTo + 92 26 CoreFoundation 0x21b24 invoking_ + 148 27 CoreFoundation 0x3f610 -[NSInvocation invoke] + 468 28 OneSignalCore 0x4984 +[SwizzlingForwarder callSelector:onObject:withArgs:] + 312 29 OneSignal 0x2e7b4 -[OneSignalAppDelegate oneSignalDidRegisterForRemoteNotifications:deviceToken:] + 248 30 UIKitCore 0xf6953c __63-[UIApplication pushRegistry:didUpdatePushCredentials:forType:]_block_invoke + 180 31 libdispatch.dylib 0x1e6c _dispatch_call_block_and_release + 92 32 libdispatch.dylib 0x3a30 _dispatch_client_callout + 148 33 libdispatch.dylib 0x11f48 _dispatch_main_queue_drain + 468 34 libdispatch.dylib 0x11b98 _dispatch_main_queue_callback_4CF + 312 35 CoreFoundation 0x51800 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 248 36 CoreFoundation 0xb704 __CFRunLoopRun + 180 37 CoreFoundation 0x1ebc8 CFRunLoopRunSpecific + 92 38 GraphicsServices 0x1374 GSEventRunModal + 148 39 UIKitCore 0x514648 -[UIApplication _run] + 468 40 UIKitCore 0x295d90 UIApplicationMain + 312 41 Runner 0x58c8 main + 7 (AppDelegate.swift:7) 42 ??? 0x100fa5ce4 $s6Adapty19AppDelegateSwizzlerC20swizzled_application33_882DEC7821489E8AC05D52AA1ADD858BLL_48didRegisterForRemoteNotificationsWithDeviceTokenySo13UIApplicationC_10Foundation4DataVtFTf4nnd_n + 180

x401om commented 2 years ago

Hi, @ibrahimdevs! I would suggest you to opt out of Adapty swizzling mechanism just to check everything else is fine. For now I'm not sure this is our issue, but we will investigate it and I will come back to you soon.

ibrahimdevs commented 2 years ago

Hi, @x401om thanks for quick workaround but I think that it is not an option for Flutter SDK. Because current flutter SDK is based on iOS 1.16.10 which is not supporting to opt out Adapty swizzling. This feature has been added on newer versions.

x401om commented 2 years ago

@ibrahimdevs actually it is the option for underlying iOS SDK and it presented from the beginning. Flutter SDK does not require any additional settings, you just need to add the AdaptyAppDelegateProxyEnabled key with the value NO to the app's Info.plist

ibrahimdevs commented 2 years ago

@x401om thanks for clarification. I messed it with in AppDelegateSwizzler.swift:

#if ADAPTY_DISABLE_PUSHES
#else

So I disabled it with "AdaptyAppDelegateProxyEnabled" now.

I opened this issue on OneSignal's Repo too, maybe this issue could help you to solve it. https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/577

x401om commented 2 years ago

@ibrahimdevs are you able to reproduce this crash after disabling this feature?

ibrahimdevs commented 2 years ago

@x401om it was a random bug, so I'm not 100% sure but I think disabling this feature fixed this issue. I published an update 2 days ago, after that there is no error.

kellvembarbosa commented 2 years ago

I'm having the same problem and the percentage of crashes is pretty high.

kellvembarbosa commented 2 years ago

@ibrahimdevs updates about this bug?

x401om commented 2 years ago

Hi everyone! We are planning to remove this feature in the next releases (I mean promos and therefore APNS support and swizzling mechanism), so feel free to disable this using the workaround described above. At the moment I will not close this issue until it will be done.

ibrahimdevs commented 2 years ago

@kellvembarbosa I disabled this mechanism with this workaround below. And it is working fine now.

@ibrahimdevs actually it is the option for underlying iOS SDK and it presented from the beginning. Flutter SDK does not require any additional settings, you just need to add the AdaptyAppDelegateProxyEnabled key with the value NO to the app's Info.plist