invertase / react-native-firebase

πŸ”₯ A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.66k stars 2.21k forks source link

App crash after receiving notification iOS only #4070

Closed jigaryadav11 closed 3 years ago

jigaryadav11 commented 4 years ago

Issue

whenever iOS (13.x) receives push notification the app will show crash message after 3-5 min even if the app is not opened, previously I thought it was due to background message handler but after removing the handler i am facing same issue.

IMG_6724

this issue was only in the 13.x version of iOS other versions are not facing this issue. crash report on apple console also shows no sign of the crash


Project Files

Javascript

Click To Expand

#### `package.json`: "@react-native-community/async-storage": "^1.7.1", "@react-native-community/clipboard": "^1.2.3", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^5.5.0", "@react-native-firebase/app": "^8.3.0", "@react-native-firebase/crashlytics": "^8.3.0", "@react-native-firebase/dynamic-links": "^7.4.1", "@react-native-firebase/messaging": "^7.6.1", "@react-navigation/bottom-tabs": "^5.6.1", "@react-navigation/native": "^5.6.1", "@react-navigation/stack": "^5.6.2", "@spree/storefront-api-v2-sdk": "^4.0.5", "axios": "^0.19.2", "base-64": "^0.1.0", "i18next": "^19.1.0", "moment": "^2.24.0", "react": "16.9.0", "react-i18next": "^11.3.1", "react-native": "0.61.5", "react-native-autoheight-webview": "^1.5.1", "react-native-calendars": "^1.264.0", "react-native-config": "^0.12.0", "react-native-date-picker": "^2.7.12", "react-native-gesture-handler": "^1.6.1", "react-native-keyboard-aware-scroll-view": "^0.9.1", "react-native-material-dropdown": "^0.11.1", "react-native-material-textfield": "^0.16.1", "react-native-mixpanel": "^1.2.0", "react-native-reanimated": "^1.9.0", "react-native-safe-area-context": "^0.7.3", "react-native-screens": "^2.9.0", "react-native-share": "^3.5.0", "react-native-splash-screen": "^3.2.0", "react-native-svg": "^11.0.1", "react-native-swiper": "^1.6.0-nightly.5", "react-native-switch": "git+https://github.com/shahen94/react-native-switch.git", "react-native-webview": "^10.2.3", "react-redux": "^7.1.3", "redux": "^4.0.5", "redux-logger": "^3.0.6", "redux-reset": "^0.3.0", "redux-saga": "^1.1.3", "redux-thunk": "^2.3.0", "rn-fetch-blob": "git+https://github.com/joltup/rn-fetch-blob.git", "url": "^0.11.0" ```json # N/A ``` #### `firebase.json` for react-native-firebase v6: { "react-native": { "messaging_ios_auto_register_for_remote_messages": false, "crashlytics_ndk_enabled": true, "crashlytics_debug_enabled": true } } ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS Mojave 10.14.6 CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz Memory: 39.01 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.5.0 - /usr/local/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.10.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 23, 24, 25, 26, 27, 28, 29 Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.3, 28.0.3, 29.0.0 System Images: android-28 | Google Play Intel x86 Atom Android NDK: 20.0.5594570 IDEs: Android Studio: 3.4 AI-183.5429.30.34.5452501 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: create-react-native-module: 0.5.0 react-native-cli: 2.0.1 react-native-collapsible: 0.13.0 react-native-git-upgrade: 0.2.7 react-native-rename: 2.2.2 ``` - **Platform that you're experiencing the issue on**: - [ x] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `8.3.0` - **Are you using `TypeScript`?** - `N`


mikehardy commented 4 years ago

Interesting

We can look at it once you post the crash trace from Xcode

jigaryadav11 commented 4 years ago

@mikehardy if a user sends a feedback apple is not showing any crash report from the system side. only showing feedback that user wrote in a comment, still, I got some crash report might be related

crashlog.crash.zip

mikehardy commented 4 years ago

Last Exception Backtrace:
0   CoreFoundation                  0x199961654 __exceptionPreprocess + 224 (NSException.m:199)
1   libobjc.A.dylib                 0x199683bcc objc_exception_throw + 56 (objc-exception.mm:565)
2   xyz                         0x104a96d7c RCTFatal + 668 (RCTAssert.m:146)
3   xyz                         0x104b0813c -[RCTExceptionsManager reportFatalException:stack:exceptionId:] + 496 (RCTExceptionsManager.mm:65)
4   CoreFoundation                  0x1999678c0 __invoking___ + 144
5   CoreFoundation                  0x199838a70 -[NSInvocation invoke] + 300 (NSForwarding.m:3312)
6   CoreFoundation                  0x199839648 -[NSInvocation invokeWithTarget:] + 76 (NSForwarding.m:3418)
7   xyz                         0x104ac929c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 460 (RCTModuleMethod.mm:569)
8   xyz                         0x104acb3a8 facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&) + 244
9   xyz                         0x104acb10c invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 88
10  libdispatch.dylib               0x1996269a8 _dispatch_call_block_and_release + 24 (init.c:1408)
11  libdispatch.dylib               0x199627524 _dispatch_client_callout + 16 (object.m:495)
12  libdispatch.dylib               0x199604b3c _dispatch_lane_serial_drain$VARIANT$armv81 + 564 (inline_internal.h:2484)
13  libdispatch.dylib               0x19960554c _dispatch_lane_invoke$VARIANT$armv81 + 396 (queue.c:3863)
14  libdispatch.dylib               0x19960e84c _dispatch_workloop_worker_thread + 580 (queue.c:6445)
15  libsystem_pthread.dylib         0x199678b74 _pthread_wqthread + 272 (pthread.c:2352)
16  libsystem_pthread.dylib         0x19967b740 start_wqthread + 8

This looks to me like it crashed in javasript unhandled somehow. Very strange. I don't have this behavior in my work project so I'm going to say this is likely a problem with project code. To prove that it's in the module we'll need a minimum / reproducible reproduction case - you can build one pretty quickly on current versions of everything with this as a starting point https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

Thanks for the crash log, sorry nothing obvious jumped out - it just doesn't look like a native crash. You might make sure crashlytics logging is enabled and you are getting test crashes and unhandled javascript crashes reported in it (the javascript ones might only be visible if you un-filter 'crashes' in the console) as it should show up in there

jigaryadav11 commented 4 years ago

@mikehardy maybe its a javascript crash but weird is that I have already added Crashlytics by firebase and it's not reporting any crash. this crash is related to push notification, I am somewhat sure coz crash happens after the user get push notifications

no other package handle any background process unlike https://rnfirebase.io/messaging/usage

any other device has not experienced this crash so far. in fact, debugging build never crashed and if you are using the app then also there is no sign of crash like this

do you think some weird config data is coming from notification backend? we have used REST API to send notification

mikehardy commented 4 years ago

If you can (carefully! not sending the server keys of course) show us the exact JSON you send via the API that would be helpful in trying to reproduce

Something like this (though this one is not following best practices with content-available/priority settings etc)

curl  \
  --header "Content-Type: application/json" \
  --request POST \
  --data "{\"data\": { \"fcmType\": \"DirectMessage\", \"senderKullkiId\": \"$se
nder\", \"recipientKullkiId\": \"$recipient\", \"options\": { \"title\": \"Asere
\", \"body\": \"Que vola?\" }}}" \
  $ENDPOINT
jigaryadav11 commented 4 years ago

@mikehardy
our backend API body for ios notification

{
   "data":{
      "data":{}
   },
   "priority":"high",
   "notification":{
      "body":"example body..",
      "badge":null,
      "sound":"default",
      "title":"crash issue for ios"
   },
   "registration_ids":[
      "--user token--"
   ],
   "content_available":true
}
JakeHedman commented 4 years ago

We encountered this too, the app would crash when we received a remote message (which we would have used to call notifee to display a notification). Nothing showed up in crashlytics and we ended up using remote notifications and removing the remote messaging stuff completely.

I saw this in the syslog when it happened on my device:

Aug 26 14:47:48 Jakes-iPhone dasd(DuetActivitySchedulerDaemon)[1233] <Notice>: Push not allowed for <private>
Aug 26 14:47:48 Jakes-iPhone dasd(DuetActivitySchedulerDaemon)[1233] <Notice>: Daemon Canceling Activities: {(
    com.apple.pushLaunch.com.example.app:D42824
)}
Aug 26 14:47:48 Jakes-iPhone dasd(DuetActivitySchedulerDaemon)[1233] <Notice>: CANCELED: com.apple.pushLaunch.com.example.app:D42824 at priority 5 <private>!
Aug 26 14:47:48 Jakes-iPhone dasd(DuetActivitySchedulerDaemon)[1233] <Notice>: Removing a launch request for application <private> by activity <private>
Aug 26 14:47:48 Jakes-iPhone dasd(DuetActivitySchedulerDaemon)[1233] <Error>: Activity <private> not tracked as being started, ignoring it
Aug 26 14:47:48 Jakes-iPhone SpringBoard(DuetActivityScheduler)[1738] <Notice>: cancelActivities: 1 activities were not found: <private>
mikehardy commented 4 years ago

"remote notifications" / "remote messaging", that is very imprecise language. They are all actually chunks of JSON sent from APNS to your device using the same technology. In firebase terms they are all "cloud messages" though they may trigger a visible notification from within the SDKs in play, after the JSON is received.

The logs look to me as though notifications permission was not granted?

mikehardy commented 4 years ago

Also "encountered this" - to reproduce we would need an App.js that reproduces the problem along with the JSON actually sent via the firebase admin SDK - that's how we reproduce these things

mikehardy commented 4 years ago

I can see this, so it means my app is taking too long to launch. But I dont have anything that should slow down the launch.

Evidence is to the contrary no?

You will have to instrument your code and find out what is taking so long. This is likely project-specific.

There is potential for a hang in dynamic links on IPV6 networks but you don't have that dependency listed so I'm pretty certain this will resolve to an issue in your project somehow

mikehardy commented 4 years ago

@nishanttatva I am marking your comments off-topic - no offense but they are a separate issue and clutter the main one, which is bad form in issue trackers. After careful examination of your own project using Xcode profiling tools to find why it is hanging, open a new issue if there is a problem with react-native-firebase

nishanttatva commented 4 years ago

@jigaryadav11 @JakeHedman Could you pinpoint the issue in your code? I am facing this crash on iOS 13 devices with similar stack trace.

ftlno commented 3 years ago

Same here. @jigaryadav11 @JakeHedman

ftlno commented 3 years ago

Nevermind. My issue was that I tried to use notification.payload, which were undefined..

stale[bot] commented 3 years ago

Hello πŸ‘‹, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

upacyxou commented 1 year ago

Hello! I have exactly the same problem. For some reason, some users are experiencing crashes on their devices when receiving silent notifications (iOS only), even on old client versions that have not been updated for more than four weeks and were working fine. We haven't changed anything on our backend and we can't reproduce this on our dev devices. Unfortunately, we're completely blind to this problem and don't know what to do. The crash logs and behavior are exactly the same as yours. Have you managed to find out more details and figure out this problem?