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.65k stars 2.21k forks source link

[🐛] iOS 14 Only attempt to insert nil object from objects[0] #4271

Closed sergey-g-s closed 3 years ago

sergey-g-s commented 4 years ago

Hi all. This is a problem that I only got on devices with iOS 14.

Description

My project worked well on iOS 13 and after I tried to run it on iOS 14 I always get an error in xcode

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

If you need more information let me know

React Native version:

System:
    OS: macOS 11.0
    CPU: (4) x64 Intel(R) Core(TM) i3-8100B CPU @ 3.60GHz
    Memory: 65.82 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 10.16.1 - ~/.nvm/versions/node/v10.16.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.0, DriverKit 20.0, macOS 11.0, tvOS 14.0, watchOS 7.0
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 12.0/12A8189h - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_252 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.2 => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Package:

{
  "name": "MYAPP",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start --reset-cache",
    "test": "jest",
    "lint": "eslint 'app/src/**/*.js' --fix",
    "flow": "flow",
    "lint-staged": "lint-staged"
  },
  "husky": {
    "hooks": {
      "pre-commit": "yarn flow && yarn lint-staged"
    }
  },
  "dependencies": {
    "@react-native-community/async-storage": "1.8.1",
    "@react-native-community/blur": "3.4.1",
    "@react-native-community/cameraroll": "^4.0.0",
    "@react-native-community/datetimepicker": "2.3.0",
    "@react-native-community/push-notification-ios": "1.0.7",
    "@react-native-firebase/analytics": "7.1.0",
    "@react-native-firebase/app": "7.1.0",
    "@react-native-firebase/messaging": "7.1.0",
    "@sentry/react-native": "1.3.3",
    "axios": "0.19.2",
    "compare-versions": "3.6.0",
    "dayjs": "^1.8.30",
    "diacritics": "1.3.0",
    "flow-bin": "0.105.2",
    "formik": "2.1.4",
    "immer": "^7.0.5",
    "moment": "2.24.0",
    "opentok-react-native": "0.13.0",
    "ramda": "0.27.0",
    "react": "16.13.1",
    "react-content-loader": "5.0.2",
    "react-native": "0.63.2",
    "react-native-add-calendar-event": "3.0.1",
    "react-native-android-keyboard-adjust": "tilted-tm/react-native-android-keyboard-adjust",
    "react-native-config": "1.0.0",
    "react-native-confirmation-code-field": "^6.5.0",
    "react-native-confirmation-code-input": "1.0.4",
    "react-native-credit-card-input": "0.4.1",
    "react-native-device-info": "^5.6.3",
    "react-native-easy-toast": "^1.2.0",
    "react-native-exception-handler": "2.10.8",
    "react-native-fbsdk": "^2.0.0",
    "react-native-gesture-handler": "1.6.0",
    "react-native-gifted-chat": "^0.16.3",
    "react-native-i18n": "2.0.15",
    "react-native-image-crop-picker": "0.28.0",
    "react-native-image-picker": "0.28.0",
    "react-native-image-resizer": "^1.2.3",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-in-app-notification": "3.0.1",
    "react-native-keyboard-aware-scroll-view": "^0.9.2",
    "react-native-mime-types": "^2.3.0",
    "react-native-modal": "11.5.6",
    "react-native-otp-verify": "^1.0.3",
    "react-native-platform-touchable": "1.1.1",
    "react-native-reanimated": "1.7.0",
    "react-native-router-flux": "4.2.0",
    "react-native-safe-area-context": "0.7.3",
    "react-native-safe-area-view": "1.0.0",
    "react-native-screens": "2.3.0",
    "react-native-splash-screen": "3.2.0",
    "react-native-svg": "12.0.3",
    "react-native-svg-transformer": "0.14.3",
    "react-native-swiper": "1.6.0-rc.1",
    "react-native-vector-icons": "^7.0.0",
    "react-native-webview": "9.0.1",
    "react-native-wheel-picker": "tilted-tm/react-native-wheel-picker",
    "react-navigation": "4.2.2",
    "react-redux": "7.2.0",
    "reactotron-react-native": "4.0.2",
    "reactotron-redux": "3.1.2",
    "reactotron-redux-saga": "4.2.2",
    "redux": "4.0.5",
    "redux-devtools": "^3.5.0",
    "redux-devtools-extension": "^2.13.8",
    "redux-logger": "3.0.6",
    "redux-persist": "6.0.0",
    "redux-saga": "1.1.3",
    "remove-accents": "^0.4.2",
    "rn-fetch-blob": "^0.12.0",
    "seamless-immutable": "7.1.4",
    "styled-components": "^5.1.1",
    "tipsi-stripe": "8.0.0-beta.10",
    "webrtc-adapter": "^7.6.3"
  },
  "devDependencies": {
    "@babel/core": "7.8.7",
    "@babel/runtime": "7.8.7",
    "@bam.tech/react-native-make": "2.0.0",
    "@react-native-community/eslint-config": "0.0.7",
    "babel-jest": "25.1.0",
    "eslint": "6.8.0",
    "eslint-config-standard": "14.1.0",
    "eslint-config-standard-react": "9.2.0",
    "eslint-plugin-flowtype": "4.6.0",
    "eslint-plugin-import": "2.20.1",
    "eslint-plugin-node": "11.0.0",
    "eslint-plugin-promise": "4.2.1",
    "eslint-plugin-react": "7.19.0",
    "eslint-plugin-standard": "4.0.1",
    "husky": "4.2.3",
    "jest": "25.1.0",
    "lint-staged": "10.0.8",
    "metro-react-native-babel-preset": "0.58.0",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "lint-staged": {
    "*.js": [
      "eslint --fix"
    ]
  }
}

Pods:

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native/scripts/react_native_pods'

platform :ios, '10.0'

target 'MYAPP' do
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  target 'MYAPPTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

Log:

2020-09-17 15:23:46.876152+0300 MYAPP[4143:493632] <Warning>: Please set a value for FacebookAutoLogAppEventsEnabled. Set the flag to TRUE if you want to collect app install, app launch and in-app purchase events automatically. To request user consent before collecting data, set the flag value to FALSE, then change to TRUE once user consent is received. Learn more: https://developers.facebook.com/docs/app-events/getting-started-app-events-ios#disable-auto-events.
    2020-09-17 15:23:46.877416+0300 MYAPP[4143:493632] <Warning>: You haven't set a value for FacebookAdvertiserIDCollectionEnabled. Set the flag to TRUE if you want to collect Advertiser ID for better advertising and analytics results.
2020-09-17 15:24:47.234399+0300 MYAPP[4143:493866] Task <3B7D3C61-B3E5-4E92-B884-E98B86FF97E9>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x2822729d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <3B7D3C61-B3E5-4E92-B884-E98B86FF97E9>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <3B7D3C61-B3E5-4E92-B884-E98B86FF97E9>.<1>"
), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=http://192.168.0.105:8081/status, NSErrorFailingURLKey=http://192.168.0.105:8081/status, _kCFStreamErrorDomainKey=4}
2020-09-17 15:24:47.256281+0300 MYAPP[4143:493632] [native] Running application MYAPP ({
initialProps =     {
};
rootTag = 1;
})
2020-09-17 15:24:47.268978+0300 MYAPP[4143:493881] 6.25.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.
2020-09-17 15:24:47.312992+0300 MYAPP[4143:493866] 6.25.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2020-09-17 15:24:47.317115+0300 MYAPP[4143:493866] 6.25.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-09-17 15:24:47.340982+0300 MYAPP[4143:493866] 6.25.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60501000 started
2020-09-17 15:24:47.341770+0300 MYAPP[4143:493866] 6.25.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2020-09-17 15:24:47.410764+0300 MYAPP[4143:493992] [Client] Updating selectors after delegate removal failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 88 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 88 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
2020-09-17 15:24:47.429141+0300 MYAPP[4143:493632] FBSDKLog: fb-messenger-share-api is missing from your Info.plist under LSApplicationQueriesSchemes and is required for iOS 9.0
2020-09-17 15:24:47.429431+0300 MYAPP[4143:493632] FBSDKLog: fbauth2 is missing from your Info.plist under LSApplicationQueriesSchemes and is required for iOS 9.0
2020-09-17 15:24:47.431858+0300 MYAPP[4143:493881] [tcp] tcp_input [C2.1:3] flags=[R] seq=2910663435, ack=0, win=0 state=CLOSED rcv_nxt=2910663435, snd_una=2084476413
2020-09-17 15:24:47.432180+0300 MYAPP[4143:493881] [tcp] tcp_input [C2.1:3] flags=[R] seq=2910663435, ack=0, win=0 state=CLOSED rcv_nxt=2910663435, snd_una=2084476413
2020-09-17 15:24:47.436111+0300 MYAPP[4143:493632] FBSDKLog: starting with Graph API v2.4, GET requests for /195739114824780/model_asset should contain an explicit "fields" parameter
2020-09-17 15:24:47.471741+0300 MYAPP[4143:493881] [tcp] tcp_input [C1.1:3] flags=[R] seq=2629399053, ack=0, win=0 state=CLOSED rcv_nxt=2629399053, snd_una=3107602082
2020-09-17 15:24:47.471909+0300 MYAPP[4143:493881] [tcp] tcp_input [C1.1:3] flags=[R] seq=2629399053, ack=0, win=0 state=CLOSED rcv_nxt=2629399053, snd_una=3107602082
2020-09-17 15:24:47.572210+0300 MYAPP[4143:494213] 6.25.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-09-17 15:25:07.703378+0300 MYAPP[4143:494224] [tcp] tcp_output [C14.1:3] flags=[R.] seq=912352729, ack=2533363381, win=4096 state=CLOSED rcv_nxt=2533363381, snd_una=912352729
2020-09-17 15:25:07.705428+0300 MYAPP[4143:494224] Connection 14: received failure notification
2020-09-17 15:25:07.705746+0300 MYAPP[4143:494224] Connection 14: failed to connect 3:-9816, reason -1
2020-09-17 15:25:07.705837+0300 MYAPP[4143:494224] Connection 14: encountered error(3:-9816)
2020-09-17 15:25:18.335269+0300 MYAPP[4143:494219] [tcp] tcp_output [C15.1:3] flags=[R.] seq=2353633686, ack=248484103, win=4096 state=CLOSED rcv_nxt=248484103, snd_una=2353633686
2020-09-17 15:25:18.338275+0300 MYAPP[4143:494219] Connection 15: received failure notification
2020-09-17 15:25:18.339071+0300 MYAPP[4143:494219] Connection 15: failed to connect 3:-9816, reason -1
2020-09-17 15:25:18.340516+0300 MYAPP[4143:494219] Connection 15: encountered error(3:-9816)
2020-09-17 15:25:18.416619+0300 MYAPP[4143:494224] [boringssl] boringssl_context_handle_fatal_alert(1763) [C17.1:2][0x10720d610] read alert, level: fatal, description: inappropriate fallback
2020-09-17 15:25:18.418166+0300 MYAPP[4143:494224] [boringssl] boringssl_session_handshake_incomplete(90) [C17.1:2][0x10720d610] SSL library error
2020-09-17 15:25:18.418648+0300 MYAPP[4143:494224] [boringssl] boringssl_session_handshake_error_print(41) [C17.1:2][0x10720d610] Error: 4360096920:error:1000043e:SSL routines:OPENSSL_internal:TLSV1_ALERT_INAPPROPRIATE_FALLBACK:/Library/Caches/com.apple.xbs/Sources/boringssl/boringssl-351.0.1/ssl/tls_record.cc:592:SSL alert number 86
2020-09-17 15:25:18.419022+0300 MYAPP[4143:494224] [boringssl] nw_protocol_boringssl_handshake_negotiate_proceed(761) [C17.1:2][0x10720d610] handshake failed at state 12288: not completed
2020-09-17 15:25:18.423447+0300 MYAPP[4143:494224] Connection 17: received failure notification
2020-09-17 15:25:18.424619+0300 MYAPP[4143:494224] Connection 17: failed to connect 3:-9860, reason -1
2020-09-17 15:25:18.424861+0300 MYAPP[4143:494224] Connection 17: encountered error(3:-9860)
2020-09-17 15:25:18.427595+0300 MYAPP[4143:494224] Task <145461A1-5355-49F3-B990-A63ADD61AEBF>.<1> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9860])
2020-09-17 15:25:48.269210+0300 MYAPP[4143:494224] Task <E0E85B74-2BA3-4904-AF29-40B7B2C0B08B>.<2> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x282277b10 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E0E85B74-2BA3-4904-AF29-40B7B2C0B08B>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <E0E85B74-2BA3-4904-AF29-40B7B2C0B08B>.<2>"
), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=http://192.168.0.105:8081/status, NSErrorFailingURLKey=http://192.168.0.105:8081/status, _kCFStreamErrorDomainKey=4}
2020-09-17 15:25:48.317358+0300 MYAPP[4143:494412] [connection] nw_socket_handle_socket_event [C18.1:1] Socket SO_ERROR [61: Connection refused]
2020-09-17 15:25:48.320763+0300 MYAPP[4143:494412] [connection] nw_socket_handle_socket_event [C18.2:1] Socket SO_ERROR [61: Connection refused]
2020-09-17 15:25:48.321604+0300 MYAPP[4143:494239] [connection] nw_connection_get_connected_socket [C18] Client called nw_connection_get_connected_socket on unconnected nw_connection
2020-09-17 15:25:48.321674+0300 MYAPP[4143:494239] TCP Conn 0x281b3c420 Failed : error 0:61 [61]
2020-09-17 15:25:48.346472+0300 MYAPP[4143:494555] 6.25.0 - [Firebase/Messaging][I-FCM012002] Error in application:didFailToRegisterForRemoteNotificationsWithError: (null)
2020-09-17 15:25:48.355030+0300 MYAPP[4143:493632] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x19c40a5ac 0x1b048442c 0x19c4794cc 0x19c485608 0x19c2fec8c 0x19c2f1840 0x1009e3350 0x10070c4c4 0x10094c264 0x103aa3b68 0x103aa55f0 0x103ab4890 0x19c3871e4 0x19c3813b4 0x19c3804bc 0x1b2e05820 0x19ed24734 0x19ed29e10 0x10070c994 0x19c047e60)
libc++abi.dylib: terminating with uncaught exception of type NSException
mikehardy commented 4 years ago

our app module is at 8.4.2 and messaging is at 7.8.6 firebase-ios-sdk is at 6.32.2 (override to get that like so: https://rnfirebase.io/#ios / https://github.com/mikehardy/rnfbdemo/blob/9e80bacc9b62961f89246eea82dd956f4f8660f8/make-demo.sh#L40)

ios 14 is new, I would presume there are all sorts of crash bugs present in older versions

Can you update to current stable versions and re-attempt reproduction?

mikehardy commented 4 years ago

also if you can reproduce on new versions, a full stack trace is vital to diagnose and fix crash issues with an App.js that shows the reproduction also being very important, please include that so we can troubleshoot.

sergey-g-s commented 4 years ago

@mikehardy I updated firebase to the latest version but get the same error

    "@react-native-community/push-notification-ios": "1.5.0",
    "@react-native-firebase/analytics": "7.6.2",
    "@react-native-firebase/app": "8.4.2",
    "@react-native-firebase/messaging": "7.8.6",

Stack trace

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001c833398c libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001e395bc74 libsystem_pthread.dylib`pthread_kill + 272
    frame #2: 0x00000001a550cbb4 libsystem_c.dylib`abort + 104
    frame #3: 0x00000001b0583e24 libc++abi.dylib`abort_message + 132
    frame #4: 0x00000001b0575434 libc++abi.dylib`demangling_terminate_handler() + 308
    frame #5: 0x00000001b0484710 libobjc.A.dylib`_objc_terminate() + 132
    frame #6: 0x00000001b05832a8 libc++abi.dylib`std::__terminate(void (*)()) + 20
    frame #7: 0x00000001b0583234 libc++abi.dylib`std::terminate() + 44
    frame #8: 0x00000001b048468c libobjc.A.dylib`objc_terminate + 16
    frame #9: 0x00000001073e1604 libdispatch.dylib`_dispatch_client_callout + 40
    frame #10: 0x00000001073f0890 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1000
    frame #11: 0x000000019c3871e4 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
    frame #12: 0x000000019c3813b4 CoreFoundation`__CFRunLoopRun + 2508
    frame #13: 0x000000019c3804bc CoreFoundation`CFRunLoopRunSpecific + 600
    frame #14: 0x00000001b2e05820 GraphicsServices`GSEventRunModal + 164
    frame #15: 0x000000019ed24734 UIKitCore`-[UIApplication _run] + 1072
    frame #16: 0x000000019ed29e10 UIKitCore`UIApplicationMain + 168
  * frame #17: 0x0000000104013094 May Santé`main(argc=1, argv=0x000000016bdf3740) at main.m:14:12
    frame #18: 0x000000019c047e60 libdyld.dylib`start + 4
mikehardy commented 4 years ago

Sorry to be pedantic, but there is no "firebase". It appears you "updated react-native-firebase modules". I need to verify you have updated firebase-ios-sdk to 6.32.2 (current stable https://firebase.google.com/support/release-notes/ios) via the override capability here: https://rnfirebase.io/#ios

sergey-g-s commented 4 years ago

@mikehardy I added the FirebaseSDKVersion to my Podfile, and now I'm guaranteed to use the current version of firebase-ios-sdk

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native/scripts/react_native_pods'

$FirebaseSDKVersion = '6.32.2'

platform :ios, '10.0'

target 'MYAPP' do
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  target 'MYAPPTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

But the problem continues. Any ideas?

mikehardy commented 4 years ago

No ideas yet - but I needed to know I wasn't chasing an already-fixed bug before I spent a single second actually investigating, I'm only one person and guard my time carefully ;-)

mikehardy commented 4 years ago

Is this on a real device or simulator? I've just updated my test real device to ios14 and I'm working through Xcode 12 issues at the moment, so it's at least possible to test. Also if you have an App.js that reproduces that would help a ton

sergey-g-s commented 4 years ago

@mikehardy The problem appears on both the emulator and the real device. Also, I don't know exactly which file is causing this problem, so I don't know what exactly will help you repeat this. If you need any more information I will try to give it to you

mikehardy commented 4 years ago

great - would still love an App.js as I just did a rebuild of my work project with Xcode 12, firebase-ios-sdk 6.32.2 and current stable react-native-firebase modules on the emulator and it worked. So currently I can't reproduce but I do love fixing crash bugs. If you can make an example App.js (or maybe example github repo based off of https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh - just remove any modules you don't want though) that would help, otherwise this may sit a while as I'm not crashing in my work project

mikehardy commented 4 years ago

incidentally the original post you made looks a lot like your network is down or you are attempting to use the simulator and it's down

, NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=http://192.168.0.105:8081/status, NSErrorFailingURLKey=http://192.168.0.105:8081/status, _kCFStreamErrorDomainKey=4}

and the crash is a messaging registration error. I wonder if this crash is network-dependent somehow. I think iOS14 requires permission for local network usage, perhaps you need to request that (react-native-permissions just got a PR for it if I understand correctly) and then ios14 works?

In other words this may be development-environment-specific as react-native development uses the local network, and on releases we only use the internet.

That is something that is testable, if you incorporate the PR for local network usage in react-native-permissions and then request it

ArsalanCsquare commented 3 years ago

@Sergey-grishko were you able to resolve this?

Kilowhisky commented 3 years ago

I just started having this after upgrading to iOS 14. I was able to resolve the issue with the url failing by adding my machine ip address to the NSEXceptionDomains list but that still hasn't stopped it from crashing with the error referenced in the first post.

mikehardy commented 3 years ago

We never got an App.js that reproduced this when dropped in clean project result from https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh - crashes are usually easy to fix when we reproduce but we need a clean reproduction

cryptoman04 commented 3 years ago

@Sergey-grishko did you happen to solve this issue?

nthchild1 commented 3 years ago

Why is this closed without a solution? I'm facing this exact same issue.

mikehardy commented 3 years ago

@TKY2048 Because the original author closed it. They can do that.

It is not possible to have the exact same issue, as an issue is the combination of a problem you see, and the execution environment you're using. Current react-native-firebase is v12.1.0, so you'll be having a related but different issue as you should be on current versions for support requests.

You should open a new issue using current versions with the details we request in the template, and ideally an App.js we can throw into a clean app (which you may create with https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh) so we have a https://stackoverflow.com/help/minimal-reproducible-example

ArthurDias01 commented 2 years ago

I'm having a very similar issue...

I have a function that I use to upload images to my firebase storage but it sometimes works and sometimes it doesn't. The app is in production and this is a problem with a core functionality so it is very urgent to soilve it.

In this case, the error only happens on iOS, but the error is intermittent, I imagined that it was a problem with the type of img (sometimes Heic on the iPhone) but what I saw is that even using a package to solve this problem and transform to jpg the error continues to occur intermittently.


Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]' was thrown while invoking sendRequest on target Networking with params (
        {
        data =         {
            blob =             {
                "__collector" =                 {
                };
                blobId = "e12eb198-5ff7-4aab-b034-230d83ae0d6f";
                lastModified = 1649353773943;
                offset = 0;
                size = 2505742;
                type = "";
            };
            trackingName = unknown;
        };
        headers =         {
            authorization = "Firebase eyJhbGciOiJSUzI1NiIsImtpZCI6IjZhNGY4N2ZmNWQ5M2ZhNmVhMDNlNWM2ZTg4ZWVhMGFjZDJhMjMyYTkiLCJ0eXAiOiJKV1QifQ.eyJuYW1lIjoiQXJ0aHVyIERpYXMiLCJwaWN0dXJlIjoiaHR0cHM6Ly9maXJlYmFzZXN0b3JhZ2UuZ29vZ2xlYXBpcy5jb20vdjAvYi9hbGx1YWdyb2Rhc2hiLmFwcHNwb3QuY29tL28vQ2xpZW50ZSUyRjk3Z2drNHRXdUdoNXpCSElzVUkzTUtram5mZDI_YWx0PW1lZGlhJnRva2VuPTYzYmRlMDc1LTA1OTgtNDliYi1hMjFiLWFmOGE4OGI1NTBlMyIsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9hbGx1YWdyb2Rhc2hiIiwiYXVkIjoiYWxsdWFncm9kYXNoYiIsImF1dGhfdGltZSI6MTY0OTM1MDA4NiwidXNlcl9pZCI6Ijk3Z2drNHRXdUdoNXpCSElzVUkzTUtram5mZDIiLCJzdWIiOiI5N2dnazR0V3VHaDV6QkhJc1VJM01La2puZmQyIiwiaWF0IjoxNjQ5MzUzNjkyLCJleHAiOjE2NDkzNTcyOTIsImVtYWlsIjoiYXJ0aHVyc2FudG9zMDFAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZ29vZ2xlLmNvbSI6WyIxMDYyNTI5NzMyNzkwODE1ODkwMDAiXSwiZW1haWwiOlsiYXJ0aHVyc2FudG9zMDFAZ21haWwuY29tIl19LCJzaWduX2luX3Byb3ZpZGVyIjoiZ29vZ2xlLmNvbSJ9fQ.TlFIaSCSiWIiei2ooSpNHdg_9Jz_re-YaTsWKNpkXmonJF1rOwbdcG2Wut5vPcJ1Rto5deMrHMAkJGED6RT_U2VQ8xTj1ZJsiAoMFyyZM9nEhaIuNZxkx00v3PmFcJLa6q-t5q9uAHHN76sdRBzWtLcy4vGNv2JT5WBRzdrGUfwll6MDDylYVQOSLPoPDhu4z2gqFmWBsB3aMf8V5Jcvp7daWM5rNsZ4wDptXevA1vJwhUANEeQqZxIVH5LUEvzcAVvge_WEIH67joGkaRhftsttGcFeKUUskLD94AvZLNOyD0BW1I3qYWXiqOXNATsTOZGXQiGJ2Dj_AQW5QPQEEw";
            "content-type" = "multipart/related; boundary=868514014566510930255894326826394";
            "x-firebase-storage-version" = "webjs/9.6.6";
            "x-goog-upload-protocol" = multipart;
        };
        incrementalUpdates = 1;
        method = POST;
        responseType = text;
        timeout = 0;
        url = "https://firebasestorage.googleapis.com/v0/b/alluagrodashb.appspot.com/o?name=Cliente%2F97ggk4tWuGh5zBHIsUI3MKkjnfd2%2FMaquina%2F-N-48GZu-KwNXOEh6rB2_-N-48KCkM1TJIaW95yea";
        withCredentials = 1;
    },
    25903
)
callstack: (
    0   CoreFoundation                      0x00007fff20406d94 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007fff201a4a85 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff20487f47 _CFThrowFormattedException + 200
    3   CoreFoundation                      0x00007fff2049243d -[__NSPlaceholderDictionary initWithCapacity:].cold.1 + 0
    4   CoreFoundation                      0x00007fff2047582f -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 251
    5   CoreFoundation                      0x00007fff204059e8 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49
    6   Alluagro                            0x000000010335128a -[RCTBlobManager handleNetworkingRequest:] + 746
    7   Alluagro                            0x0000000103386cc6 -[RCTNetworking processDataForHTTPQuery:callback:] + 1654
    8   Alluagro                            0x0000000103385afc -[RCTNetworking buildRequest:completionBlock:] + 3660
    9   Alluagro                            0x000000010338c92c -[RCTNetworking sendRequest:callback:] + 1372
    10  CoreFoundation                      0x00007fff2040d76c __invoking___ + 140
    11  CoreFoundation                      0x00007fff2040aadf -[NSInvocation invoke] + 305
    12  CoreFoundation                      0x00007fff2040ad72 -[NSInvocation invokeWithTarget:] + 70
    13  Alluagro                            0x0000000103243446 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2534
    14  Alluagro                            0x000000010324763a _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1402
    15  Alluagro                            0x0000000103246eec _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 140
    16  Alluagro                            0x0000000103246e59 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
    17  libdispatch.dylib                   0x00007fff201148e4 _dispatch_call_block_and_release + 12
    18  libdispatch.dylib                   0x00007fff20115b25 _dispatch_client_callout + 8
    19  libdispatch.dylib                   0x00007fff2011c0df _dispatch_lane_serial_drain + 753
    20  libdispatch.dylib                   0x00007fff2011ccc1 _dispatch_lane_invoke + 400
    21  libdispatch.dylib                   0x00007fff2012797b _dispatch_workloop_worker_thread + 779
    22  libsystem_pthread.dylib             0x00007fff6fa12fd0 _pthread_wqthread + 326
    23  libsystem_pthread.dylib             0x00007fff6fa11f57 start_wqthread + 15
)

RCTFatal
facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_lane_serial_drain
_dispatch_lane_invoke
_dispatch_workloop_worker_thread
_pthread_wqthread
start_wqthread

// the function that I found it to be getting an error is:

async function uploadImageAnuncioAsync(uri: string, ObjectId: string, storage: any, userId: string, type: 'Maquina' | 'AreasDeProducao') {
    console.log('uri', uri);
    const blob: Blob = await new Promise((resolve, reject) => {
      const xhr = new XMLHttpRequest();
      xhr.onload = function () {
        resolve(xhr.response);
      };
      xhr.onerror = function (e) {
        console.log(e);
        reject(new TypeError("Network request failed"));
      };
      xhr.responseType = "blob";
      xhr.open("GET", uri, true);
      xhr.send(null);
    });

    const metadata = {
      contentType: "image/jpeg",
    };

    try {
      const timeOutFunc = setTimeout(() => {
        setSending(false);
        return Alert.alert('Erro!', 'Erro no salvamento do anúncio. Tente novamente.')
        // throw Error('Erro ao subir imagens. Tente Novamente')
      }, 7000);
      const storageRef = ref(storage, `Cliente/${userId}/${type}/${ObjectId}_${firebaseUUID()()}`);

      // const img = await fetch(uri);
      // const bytes = await img.blob();
      if (typeof uri !== 'string') {
        throw Error('Erro: nao foi possivel fazer o upload de img. Erro de conexão. Codigo (99)')
      }
      console.log('BEFORE UPLOADBYTES', blob.type)

      const uploadTask = await uploadBytes(storageRef, blob as Blob, metadata).catch(error => { console.log('ERRO ON UPLOAD BYTES', error); throw Error(error) })
      const downloadURL = await getDownloadURL(storageRef);
      clearTimeout(timeOutFunc);
      blob.close();

      return downloadURL;
    } catch (error: any) {
      console.log('ERRO NO BLOB', error)
      // Alert.alert('Erro no blob')
      setSending(false);
      throw Error(`ERRO! ${error}`)
    }

  }

it can be simplified to reproduce the error.

This is a major issue I'm getting so if anyone can help even with some kind of tip it would be awesome. Thanks

npw3202 commented 2 years ago

@ArthurDias01 did you find a resolution to your issue? I experienced the same thing in my app. @mikehardy is the issue mentioned above referenced in any existing issue or should I open a new one to track it?

ArthurDias01 commented 2 years ago

@ArthurDias01 did you find a resolution to your issue? I experienced the same thing in my app. @mikehardy is the issue mentioned above referenced in any existing issue or should I open a new one to track it?

TBH I tried literally everything I could find on this issue (which wasn't much), re-factored the functions that were calling the uploads and I kept seeing the issue on the simulator, whereas in the app itself it somehow stopped. Not sure how.

mikehardy commented 2 years ago

If you are still seeing this, please open a new issue while using up to date versions of everything (react-native 0.68.2 / current versions here, not overriding firebase-ios-sdk so should be 8.15.0 right now - not 9.1.0 yet) yet, and an App.js that reproduces (may be the one above?)

The stack trace doesn't seem to have anything react-native-firebase related in it other than the URL. So I'm not sure if this will be a react-native issue or a firebase-ios-sdk issue. Or it could be in this library as well - it appears there was an upstream issue closed like so: https://github.com/firebase/firebase-ios-sdk/issues/4391 - but if we have a similar issue it might be a result of kind of "garbage in / garbage out" where react-native-firebase could protect better against empty values but then instead of crashing we would be rejecting a promise and failing your upload, just with a more descriptive message about exactly which part of the required upload was empty ("garbage in")

If that hypothesis (something null is going down from your app code in javascript through react-native-firebase and crashing in firebase-ios-sdk) is right, it should turn up as something you can put logging around: logging ever parameter that goes in to the storage upload call to make sure it's not null / undefined, and I would expect (though could be wrong) your crash case is going to have some unexpected empty value

nickjuntilla commented 10 months ago

For anyone else coming here who has this problem it may be because you have a hidden firebase upload error. It turns out because one of my upload rules was preventing the upload it was failing, but because react native has a hard time with async hooks it was sucking up the error instead of displaying it. Once I turned the async function back into a .then function I was able to see the error.

ArthurDias01 commented 9 months ago

So after one year this came back at me on another company 🤣

and we could find a way that fixed for us.

This is our source for the upload img function.

import { Media } from '@models/shared/Media'
import { getDownloadURL, ref, uploadBytesResumable } from 'firebase/storage'

import { storage } from './db'

export const uploadImageAsync = async (location: string, media: Media): Promise<Media> => {

  return new Promise(async (resolve, reject): Promise<void> => {
    const filePath = await fetch(media.storageUrl)
    const blob = await filePath.blob()

    const storageRef = ref(storage(), location)
    const uploadTask = uploadBytesResumable(storageRef, blob)

    uploadTask.on(
      'state_changed',
      (snapshot) => {
        switch (snapshot.state) {
          case 'paused':
            break
          case 'running':
            break
        }
      },
      (error) => {
        // A full list of error codes is available at
        // https://firebase.google.com/docs/storage/web/handle-errors
        switch (error.code) {
          case 'storage/unauthorized':
            // User doesn't have permission to access the object
            break
          case 'storage/canceled':
            // User canceled the upload
            break
          case 'storage/unknown':
            break
        }
        reject(error)
      },
      async () => {
        // We're done with the blob, close and release it
        try {
          //@ts-ignore
          blob.close()
        } catch (error) {
          //blob close seems to throw an error on web, but works on android
        }

        // Upload completed successfully, now we can get the download URL
        resolve({ storageUrl: await getDownloadURL(storageRef), type: media.type })
      },
    )
  })
}
vsquared10 commented 7 months ago

Thank you so much @ArthurDias01! Your follow up helped solve the same issue for my project. Also for the same/similar use case-- using Expo Image Picker to upload a photo, which was causing the app to crash without much of a breadcrumb trail to follow. Many thanks!!!