infobip / mobile-messaging-react-native-plugin

Mobile Messaging SDK plugin for React Native projects
24 stars 4 forks source link

Runtime Crash on Android Prod Releases #49

Closed flavio-dias-mm closed 1 year ago

flavio-dias-mm commented 1 year ago

Hello there! We are getting the following error about 30 times a day, according to Firebase Crashlytics in our project:

Fatal Exception: java.lang.RuntimeException Unable to destroy activity {br.com.madeiramadeira/br.com.madeiramadeira.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule$5@f769ba4 android.app.ActivityThread.performDestroyActivity (ActivityThread.java:4969) android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:4998) android.app.servertransaction.DestroyActivityItem.execute (DestroyActivityItem.java:44) android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176) android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97) android.app.ActivityThread$H.handleMessage (ActivityThread.java:2041) android.os.Handler.dispatchMessage (Handler.java:107) android.os.Looper.loop (Looper.java:214) android.app.ActivityThread.main (ActivityThread.java:7386) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:980)

And the cause is supposedly at:

org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule.unregisterBroadcastReceiver (ReactNativeMobileMessagingModule.java:411)

At the starting of the app we are calling mobileMessaging.register, and as a callback on unmounting the app, we're calling mobileMessaging.unregister, where i believe the problem is occurring, but it does not make sense since the register did ok. Tho i might be wrong in this diagnosis, i did not found anything useful regarding this problem in the wiki or documentation.

We are using version 6.0.0 of infobip-mobile-messaging-react-native-plugin, react-native 0.66.3, react 17.0.2.

We are getting app code to the sdk according to past issue here, and also as the past problems, various devices, from samsung, motorola, to xiaomi, in Android 8 and below, 9, 10 and 11.

Since now, thanks for the attention.

riskpp commented 1 year ago

Hello @flavio-dias-mm, thank you for the detailed description. We will be able to check it next week

leofolive commented 1 year ago

@riskpp This is drastically affecting our app. I'm having about 95 errors a day.

Screen Shot 2022-07-22 at 10 23 03 Screen Shot 2022-07-22 at 10 23 18
java.lang.RuntimeException:
  at android.app.ActivityThread.performDestroyActivity (ActivityThread.java:5691)
  at android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:5736)
  at android.app.servertransaction.DestroyActivityItem.execute (DestroyActivityItem.java:44)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2336)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:247)
  at android.app.ActivityThread.main (ActivityThread.java:8676)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.IllegalArgumentException:
  at android.app.LoadedApk.forgetReceiverDispatcher (LoadedApk.java:1524)
  at android.app.ContextImpl.unregisterReceiver (ContextImpl.java:1712)
  at android.content.ContextWrapper.unregisterReceiver (ContextWrapper.java:733)
  at android.content.ContextWrapper.unregisterReceiver (ContextWrapper.java:733)
  at org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule.unregisterBroadcastReceiver (ReactNativeMobileMessagingModule.java:411)
  at org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule.onHostDestroy (ReactNativeMobileMessagingModule.java:97)
  at com.facebook.react.bridge.ReactContext.onHostDestroy (ReactContext.java:305)
  at com.facebook.react.ReactInstanceManager.moveToBeforeCreateLifecycleState (ReactInstanceManager.java:768)
  at com.facebook.react.ReactInstanceManager.onHostDestroy (ReactInstanceManager.java:657)
  at com.facebook.react.ReactInstanceManager.onHostDestroy (ReactInstanceManager.java:671)
  at com.facebook.react.ReactDelegate.onHostDestroy (ReactDelegate.java:73)
  at com.facebook.react.ReactActivityDelegate.onDestroy (ReactActivityDelegate.java:109)
  at com.facebook.react.ReactActivity.onDestroy (ReactActivity.java:64)
  at android.app.Activity.performDestroy (Activity.java:8476)
  at android.app.Instrumentation.callActivityOnDestroy (Instrumentation.java:1344)
  at android.app.ActivityThread.performDestroyActivity (ActivityThread.java:5676)

6.0.0 of infobip-mobile-messaging-react-native-plugin, react-native 0.66.3, react 17.0.2.

riskpp commented 1 year ago

Hi @flavio-dias-mm, @LFMAKER , I started checking this issue, however it looks weird because we check was broadcastReceiver registered or not before unregistering it, and mobileMessaging.register/unregister aren't connected with android broadcastReceivers. May be you have other errors in the log for starting the plugin, are you able to receive any events from mobileMessaging?

Will try to reproduce it..

flavio-dias-mm commented 1 year ago

Thanks for the reply, thats in fact weird, i'll be looking this up today and come back here with news

riskpp commented 1 year ago

I can't reproduce the issue, but noticed that you are using old methods instead of register/unregister following API should be used:

Anyway going to release version with catching Illegal argument exception while unsubscribing

flavio-dias-mm commented 1 year ago

Ohh, i'll change for the correct methods then, anyway, thanks for the help and i'm waiting for that release!

flavio-dias-mm commented 1 year ago

Any prediction for when the release will come?

riskpp commented 1 year ago

It was released already https://github.com/infobip/mobile-messaging-react-native-plugin/releases/tag/6.3.4

flavio-dias-mm commented 1 year ago

Nice, i'll update my package and apply those methods changes, and keep an eye on the crashlytics issue, since me as well wasnt able to reproduce the crash. Thank you very much for the attention!

flavio-dias-mm commented 1 year ago

Hello again, in terms of JS i could apply changes without problem, yet, on upgrading from 6.0.0 to 6.3.4, i could not build to ios successfully anymore. Looked the internet for any similar cases and couldnt find anything usefull. So here i am again. Following you documentation i checked all requirements, we're trying to upgrade your lib in one branch as follows: react native: 0.68 node: 16 ruby: 2.7.4 cocoapods: 1.11.3 target: ios 12 xcode CLT: 13.4

after following all steps of configuration for iOS, when trying to build, we get an exit with code 1, as follows:

BUILD FAILED

The following build commands failed: CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/MMLoggingUtil.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Logging/CocoaLumberjack/MMLumberjackLogger.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/MMMessageHandler.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/InteractiveNotifications/MMNotificationAction.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/InteractiveNotifications/MMNotificationCategory.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Utils/MMNSErrorExtension.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/AppOperations/MMOperation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/MMOperationQueue.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Utils/MMPostponer.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Utils/MMRenamedClassesMapping.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/HTTP/MMRequests.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/HTTP/MMResponses.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Utils/MMUserAgent.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Utils/MMUtils.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/MMVersion.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Utils/MMVersionManager.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/MobileMessaging.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/MobileMessagingService/MobileMessagingService.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Message/MOMessage.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Message/MOSendingMapper.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Message/MTMessage.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Alamofire/MultipartFormData.swift (in target 'MobileMessaging.default-Core' from project 'Pods') EmitSwiftModule normal x86_64 (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Alamofire/NetworkReachabilityManager.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Alamofire/Notifications.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/InteractiveNotifications/NotificationsInteractionService.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/Conditions/NotPendingDepersonalizationCondition.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/PSOperations/NSLock+Operations.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/PSOperations/NSOperation+Operations.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/PSOperations/Operation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/PSOperations/OperationCondition.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/PSOperations/OperationErrors.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/PSOperations/OperationObserver.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/PSOperations/OperationQueue.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Alamofire/ParameterEncoding.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/AppOperations/PersonalizeOperation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Kingsfisher/Placeholder.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/PrivacySettings.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/AppOperations/RegistrationResetOperation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/HTTP/RemoteAPIProvider.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/UserSession/RepeatingTimer.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Alamofire/Request.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Kingsfisher/RequestModifier.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Kingsfisher/Resource.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Alamofire/Response.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/CryptoSwift/UInt32+Extension.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/CryptoSwift/Updatable.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/AppOperations/UpdateInstanceOperation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/AppOperations/UpdateUserOperation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/User/UserDataMapper.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/User/UserDataService.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/UserEventsManager.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/UserNotificationCenterDelegate.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Utils/UserNotificationType.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/UserSession/UserSessionMapper.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/AppOperations/UserSessionPersistingOperation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/InternalStorage/UserSessionReportObject.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/InternalStorage/UserSessionReportObject+CoreDataProperties.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/UserSession/UserSessionService.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/Operations/AppOperations/UserSessionsReportingOperation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Core/User/UserStandardAttributeModels.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/CryptoSwift/Utils.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/Vendor/Alamofire/Validation.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/InteractiveNotifications/WebViewController/WebViewController.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/InteractiveNotifications/WebViewController/WebViewSettings.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwift normal x86_64 /Users/flavio.neto/Documents/MM-native-app/ios/Pods/MobileMessaging/Classes/InteractiveNotifications/WebViewController/WebViewToolbar.swift (in target 'MobileMessaging.default-Core' from project 'Pods') CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'MobileMessaging.default-Core' from project 'Pods') (67 failures)

Any help is welcome.

riskpp commented 1 year ago

Hello @flavio-dias-mm , could you try may be to do pod deintegrate && pod update commands.

I've found something similar here - https://github.com/facebook/react-native/issues/28777#issuecomment-835345857

flavio-dias-mm commented 1 year ago

@riskpp sadly I already tried all that even before coming here again ): We decided then to try the solution only changing our javascript methods and adding the subscribe method on the callback of init, assuring it wont be called before the initialization is done. Which kinda makes sense for me. This will soon be release on prod and we will keep tracking that error of when i opened the issue, hopefully we will succeed.

Nevertheless, i am grateful for your help and in case that keeps occurring we will come back! Thanks!