Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛] Firestore crash on user authentication on iOS only #7695

Closed
2 of 7 tasks
rgomezp opened this issue Mar 21, 2024 · 58 comments
Closed
2 of 7 tasks

[🐛] Firestore crash on user authentication on iOS only #7695

rgomezp opened this issue Mar 21, 2024 · 58 comments

Comments

@rgomezp
Copy link

rgomezp commented Mar 21, 2024

Issue

App crashes after Google authentication using Google Sign In. Then, always immediately on open.

Crash logs mention SSL issue with Firestore.

This is happening on a Testflight installed app. I can't reproduce it in a simulator.

Incident Identifier: CD4E8B71-D9A9-4F1A-A6B1-0AE9CE0A509E
Hardware Model:      iPhone15,3
Process:             MyApp [728]
Path:                /private/var/containers/Bundle/Application/55EB39DB-14C8-4B3F-AA7F-F9CD9CA04CAB/MyApp.app/MyApp
Identifier:          com.myorg.MyApp
Version:             0.0.8 (13)
AppStoreTools:       15E204
AppVariant:          1:iPhone15,3:17
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.myorg.MyApp [785]

Date/Time:           2024-03-21 02:12:53.7394 -0500
Launch Time:         2024-03-21 02:12:53.3163 -0500
OS Version:          iPhone OS 17.2.1 (21C66)
Release Type:        User
Baseband Version:    2.20.06
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: MyApp [728]

Triggered by Thread:  1


Thread 0 name:
Thread 0:
0   libsystem_kernel.dylib        	0x00000001f4a81178 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	0x00000001f4a80f10 mach_msg2_internal + 80 (mach_msg.c:201)
2   libsystem_kernel.dylib        	0x00000001f4a80e28 mach_msg_overwrite + 436 (mach_msg.c:0)
3   libsystem_kernel.dylib        	0x00000001f4a80c68 mach_msg + 24 (mach_msg.c:323)
4   CoreFoundation                	0x00000001ad357b1c __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2624)
5   CoreFoundation                	0x00000001ad355a14 __CFRunLoopRun + 1208 (CFRunLoop.c:3007)
6   CoreFoundation                	0x00000001ad355478 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
7   GraphicsServices              	0x00000001f08d64f8 GSEventRunModal + 164 (GSEvent.c:2196)
8   UIKitCore                     	0x00000001af77962c -[UIApplication _run] + 888 (UIApplication.m:3685)
9   UIKitCore                     	0x00000001af778c68 UIApplicationMain + 340 (UIApplication.m:5270)
10  MyApp                   	0x00000001009dad50 main + 76 (main.m:7)
11  dyld                          	0x00000001d008edcc start + 2240 (dyldMain.cpp:1269)

Thread 1 name:
Thread 1 Crashed:
0   libsystem_kernel.dylib        	0x00000001f4a89fbc __pthread_kill + 8
1   libsystem_pthread.dylib       	0x000000021734b680 pthread_kill + 268 (pthread.c:1681)
2   libsystem_c.dylib             	0x00000001b53d1c24 __abort + 136 (abort.c:159)
3   libsystem_c.dylib             	0x00000001b53d1b9c abort + 192 (abort.c:126)
4   libsystem_c.dylib             	0x00000001b53d0e80 __assert_rtn + 284 (assert.c:94)
5   MyApp                   	0x0000000101663948 GRPC_ec_felem_neg.cold.1 + 40 (felem.c:66)
6   MyApp                   	0x000000010155e1f0 GRPC_ec_felem_neg + 148 (felem.c:66)
7   MyApp                   	0x000000010154fa6c ec_group_set_a_minus3 + 56 (ec.c:106)
8   MyApp                   	0x000000010154e764 GRPC_EC_group_p256_do_init + 252 (ec.c:171)
9   MyApp                   	0x000000010154e764 GRPC_EC_group_p256_init + 264 (ec.c:144)
10  libsystem_pthread.dylib       	0x00000002173493d4 __pthread_once_handler + 76 (pthread.c:1935)
11  libsystem_platform.dylib      	0x000000021729ceb4 _os_once_callout + 32 (lock.c:1180)
12  libsystem_pthread.dylib       	0x00000002173497a8 pthread_once + 100 (pthread.c:1945)
13  MyApp                   	0x000000010159de20 GRPC_CRYPTO_once + 12 (thread_pthread.c:61)
14  MyApp                   	0x000000010154eb78 GRPC_EC_group_p256 + 20 (ec.c:144)
15  MyApp                   	0x000000010154eb78 GRPC_EC_GROUP_new_by_curve_name + 168 (ec.c:336)
16  MyApp                   	0x00000001015507e8 GRPC_EC_KEY_new_by_curve_name + 40 (ec_key.c:142)
17  MyApp                   	0x0000000101274018 populate_ssl_context(ssl_ctx_st*, tsi_ssl_pem_key_cert_pair const*, char const*) + 408 (ssl_transport_security.cc:843)
18  MyApp                   	0x0000000101273818 tsi_create_ssl_client_handshaker_factory_with_options(tsi_ssl_client_handshaker_options const*, tsi_ssl_client_handshaker_factory**) + 348 (ssl_transport_security.cc:2162)
19  MyApp                   	0x0000000101270574 grpc_ssl_credentials::InitializeClientHandshakerFactory(grpc_ssl_config const*, char const*, tsi_ssl_root_certs_store const*, tsi_ssl_session_cache*, tsi_ssl_client_handshaker_factory**) + 208 (ssl_credentials.cc:216)
20  MyApp                   	0x00000001012703bc grpc_ssl_credentials::grpc_ssl_credentials(char const*, grpc_ssl_pem_key_cert_pair*, grpc_ssl_verify_peer_options const*) + 172 (ssl_credentials.cc:68)
21  MyApp                   	0x0000000101270ae0 grpc_ssl_credentials::grpc_ssl_credentials(char const*, grpc_ssl_pem_key_cert_pair*, grpc_ssl_verify_peer_options const*) + 16 (ssl_credentials.cc:49)
22  MyApp                   	0x0000000101270ae0 grpc_ssl_credentials_create + 84 (ssl_credentials.cc:240)
23  MyApp                   	0x000000010133fd80 grpc::SslCredentials(grpc::SslCredentialsOptions const&) + 176 (secure_credentials.cc:134)
24  MyApp                   	0x0000000100c6c008 firebase::firestore::remote::(anonymous namespace)::CreateSslCredentials(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 60 (grpc_connection.cc:75)
25  MyApp                   	0x0000000100c6bba8 firebase::firestore::remote::GrpcConnection::CreateChannel() const + 356 (grpc_connection.cc:313)
26  MyApp                   	0x0000000100c6b954 firebase::firestore::remote::GrpcConnection::EnsureActiveStub() + 128 (grpc_connection.cc:295)
27  MyApp                   	0x0000000100c6c098 firebase::firestore::remote::GrpcConnection::CreateStream(absl::lts_20240116::string_view, firebase::firestore::credentials::AuthToken const&, std::__1::basic_string<char, std::__1::char_traits<cha... + 60 (grpc_connection.cc:341)
28  MyApp                   	0x0000000100d095ec firebase::firestore::remote::Stream::ResumeStartWithCredentials(firebase::firestore::util::StatusOr<firebase::firestore::credentials::AuthToken> const&, std::__1::basic_string<char, std::__1::char_... + 132 (stream.cc:179)
29  MyApp                   	0x0000000100d0acac firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(absl::lts_20240116::optional<firebase::firestore::util::StatusOr<firebase::firestore::credentials::AuthToken> > const&, ab... + 56 (stream.cc:154)
30  MyApp                   	0x0000000100d0acac decltype(std::declval<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(absl::lts_20240116::optional<firebase::firestore::util::StatusOr<firebase::firestore::credentials::A... + 56 (invoke.h:394)
31  MyApp                   	0x0000000100d0acac void std::__1::__invoke_void_return_wrapper<void, true>::__call<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(absl::lts_20240116::optional<firebase::firestore::util::St... + 56 (invoke.h:479)
32  MyApp                   	0x0000000100d0acac std::__1::__function::__alloc_func<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(absl::lts_20240116::optional<firebase::firestore::util::StatusOr<firebase::firestore::c... + 56 (function.h:185)
33  MyApp                   	0x0000000100d0acac std::__1::__function::__func<firebase::firestore::remote::Stream::RequestCredentials()::$_0::operator()(absl::lts_20240116::optional<firebase::firestore::util::StatusOr<firebase::firestore::credent... + 72 (function.h:359)
34  MyApp                   	0x0000000100bf9690 std::__1::__function::__value_func<void ()>::operator()[abi:v15006]() const + 20 (function.h:512)
35  MyApp                   	0x0000000100bf9690 std::__1::function<void ()>::operator()() const + 20 (function.h:1197)
36  MyApp                   	0x0000000100bf9690 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) + 68 (async_queue.cc:89)
37  MyApp                   	0x0000000100d1f934 std::__1::__function::__value_func<void ()>::operator()[abi:v15006]() const + 20 (function.h:512)
38  MyApp                   	0x0000000100d1f934 std::__1::function<void ()>::operator()() const + 20 (function.h:1197)
39  MyApp                   	0x0000000100d1f934 firebase::firestore::util::Task::ExecuteAndRelease() + 184 (task.cc:102)
40  libdispatch.dylib             	0x00000001b5319300 _dispatch_client_callout + 20 (object.m:561)
41  libdispatch.dylib             	0x00000001b5320894 _dispatch_lane_serial_drain + 748 (queue.c:3885)
42  libdispatch.dylib             	0x00000001b53213c4 _dispatch_lane_invoke + 380 (queue.c:3976)
43  libdispatch.dylib             	0x00000001b532c004 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:6913)
44  libdispatch.dylib             	0x00000001b532b878 _dispatch_workloop_worker_thread + 404 (queue.c:6507)
45  libsystem_pthread.dylib       	0x0000000217347964 _pthread_wqthread + 288 (pthread.c:2629)
46  libsystem_pthread.dylib       	0x0000000217347a04 start_wqthread + 8


Project Files

Javascript

Click To Expand

package.json:

"dependencies": {
    "@expo/vector-icons": "^13.0.0",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-firebase/analytics": "18.8.0",
    "@react-native-firebase/app": "18.8.0",
    "@react-native-firebase/auth": "18.8.0",
    "@react-native-firebase/crashlytics": "18.8.0",
    "@react-native-firebase/firestore": "18.8.0",
    "@react-native-firebase/storage": "18.8.0",
    "@react-native-google-signin/google-signin": "^10.1.1",
    "@react-navigation/bottom-tabs": "^6.0.5",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/native-stack": "^6.9.13",
    "@reduxjs/toolkit": "^1.8.0",
    "@rneui/base": "^4.0.0-rc.8",
    "@rneui/themed": "^4.0.0-rc.8",
    "@types/react-redux": "^7.1.25",
    "expo": "^49.0.11",
    "expo-asset": "~8.10.1",
    "expo-av": "~13.4.1",
    "expo-build-properties": "~0.8.3",
    "expo-constants": "~14.4.2",
    "expo-dev-client": "~2.4.13",
    "expo-font": "~11.4.0",
    "expo-image": "~1.3.5",
    "expo-keep-awake": "~12.3.0",
    "expo-linking": "~5.0.2",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "expo-updates": "~0.18.19",
    "expo-web-browser": "~12.3.2",
    "jest": "^29.2.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-native": "0.72.10",
    "react-native-chart-kit": "^6.12.0",
    "react-native-confetti-cannon": "^1.5.2",
    "react-native-copilot": "^3.2.1",
    "react-native-draggable-flatlist": "^4.0.1",
    "react-native-dropdown-picker": "^5.4.6",
    "react-native-event-listeners": "^1.0.7",
    "react-native-floating-action": "^1.22.0",
    "react-native-fontawesome": "^7.0.0",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-marquee-view": "^1.0.5",
    "react-native-reanimated": "~3.3.0",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-svg": "13.9.0",
    "react-native-ui-lib": "^7.16.0",
    "react-native-web": "~0.19.6",
    "react-native-webview": "13.2.2",
    "react-native-wheely": "^0.6.0",
    "react-redux": "^7.2.6",
    "redux": "^4.1.2",
    "rn-tooltip": "^3.0.3"
  },

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
install! 'cocoapods',
  :deterministic_uuids => false

prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...), which will be excluded. To fix this,
# you can also exclude `react-native-flipper` in `react-native.config.js`
#
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
#   }
# }
# ```
flipper_config = FlipperConfiguration.disabled
if ENV['NO_FLIPPER'] == '1' then
  # Explicitly disabled through environment variables
  flipper_config = FlipperConfiguration.disabled
elsif podfile_properties.key?('ios.flipper') then
  # Configure Flipper in Podfile.properties.json
  if podfile_properties['ios.flipper'] == 'true' then
    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"])
  elsif podfile_properties['ios.flipper'] != 'false' then
    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"], { 'Flipper' => podfile_properties['ios.flipper'] })
  end
end

target 'MyApp' do
  use_expo_modules!
  config = use_native_modules!

  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
  use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    # Note that if you have use_frameworks! enabled, Flipper will not work if enabled
    :flipper_configuration => flipper_config
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end

AppDelegate.m:

#import "AppDelegate.h"
#import <Firebase/Firebase.h>

#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// @generated begin @react-native-firebase/app-didFinishLaunchingWithOptions - expo prebuild (DO NOT MODIFY) sync-ecd111c37e49fdd1ed6354203cd6b1e2a38cccda
[FIRApp configure];
// @generated end @react-native-firebase/app-didFinishLaunchingWithOptions
  self.moduleName = @"main";

  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
}

// Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
  return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  return [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

@end



Environment

Click To Expand

react-native info output:

System:
  OS: macOS 13.0.1
  CPU: (8) arm64 Apple M1
  Memory: 53.03 MB / 8.00 GB
  Shell:
    version: 5.8.1
    path: /bin/zsh
Binaries:
  Node:
    version: 18.17.1
    path: ~/.nvm/versions/node/v18.17.1/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v18.17.1/bin/yarn
  npm:
    version: 10.4.0
    path: ~/.nvm/versions/node/v18.17.1/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.12.1
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.1 AI-221.6008.13.2211.9619390
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.22
    path: /opt/homebrew/opt/openjdk@11/bin/javac
  Ruby:
    version: 3.3.0
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: ^18.2.0
  react-native:
    installed: 0.72.10
    wanted: 0.72.10
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
  • Platform that you're experiencing the issue on:
    • 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:
    • e.g. 18.8.0
  • Firebase module(s) you're using that has the issue:
    • Firestore
  • Are you using TypeScript?
    • Y: 5.1.3


@rgomezp rgomezp added Help: Needs Triage Issue needs additional investigation/triaging. Impact: Bug New bug report labels Mar 21, 2024
@jakechao-zeal
Copy link

jakechao-zeal commented Mar 21, 2024

@rgomezp Were you able to find any reasons to why this might occur or fixes for the issue? I posted a similar issue in #7697 where I hadn't updated any codes or dependencies but now any new builds from the same branch are crashing on app open.

@rgomezp
Copy link
Author

rgomezp commented Mar 21, 2024

@jakechao-zeal ,
Unfortunately not. I'm in the same boat.

However, I'm not able to fully test authentication from scratch since on a freshly installed app the test user was already authenticated, meaning that even if I delete the app it looks like iOS hangs on to some data.

Given the code appears to be the same, I would suspect that an authentication API had a breaking change that this library is not prepared for.

I can't repro on simulator either. Started happening via a Testflight app.

@mikehardy , any ideas? I think it's an upstream issue but maybe something we can handle in this repo.

@rgomezp rgomezp changed the title [🐛] Firestore crash on user authentication [🐛] Firestore crash on user authentication on iOS only Mar 21, 2024
@rgomezp
Copy link
Author

rgomezp commented Mar 21, 2024

This issue also looks slightly different, but mentions problems with higher versions of GRPC.

Maybe we need to downgrade to the same version (1.44).

@jakechao-zeal
Copy link

I'll try and see if downgrading GRPC or maybe the firebase SDK (although as mentioned in #7666 it seems like versions lower than 10.22.0 for the IOS Firebase SDK are having build errors) helps. I'll keep you updated if I find anything and would greatly appreciate it if you update me on any findings you have. Thanks, and I hope we can get this sorted out soon!

@jakechao-zeal
Copy link

jakechao-zeal commented Mar 21, 2024

@rgomezp FYI that I posted a comment on my issue #7697 about updating to Expo SDK 50 (which required other dependency updates) and how that led to the crash going away.

I'm personally not sure if my app is ready to go to Expo SDK 50 so I'd love to see if a solution can be found for our existing package dependencies but wanted to let you know that was one solution available to us. It seems some dependency update between Expo 49 and 50 helped alleviate the issue with RNFB.

@rgomezp
Copy link
Author

rgomezp commented Mar 21, 2024

@jakechao-zeal ,
Thank you for the info. I will definitely consider updating to Expo 50 and will also let you know what I find.

FYI I opened an issue here as well: firebase/firebase-ios-sdk#12606

@nlarif
Copy link

nlarif commented Mar 22, 2024

I am facing exact same issue on Expo50, crash at startup for all iOS users (all iOS versions and phone models) while firebase auth initialization I guess.

SIGABRT Assertion failed: (borrow == 0), function GRPC_ec_felem_neg, file felem.c, line 66. > borrow == 0 > felem.c > GRPC_ec_felem_neg

@nlarif
Copy link

nlarif commented Mar 22, 2024

I fixed it by forcing update to firebase 10.23.0
I changed this file

--- a/node_modules/@react-native-firebase/app/package.json
+++ b/node_modules/@react-native-firebase/app/package.json
@@ -73,7 +73,7 @@
   },
   "sdkVersions": {
     "ios": {
-      "firebase": "10.22.0",
+      "firebase": "10.23.0",
       "iosTarget": "11.0",
       "macosTarget": "10.13"
     },

created a patch file: npx patch-package @react-native-firebase/app --exclude

then updated pod files in ios folder:
pod install --repo-update
pod update Firebase/Analytics

and rebuilt in root folder:
eas build --platform ios --local (i did it locally but I guess it should work with eas cloud build)

@rgomezp
Copy link
Author

rgomezp commented Mar 22, 2024

I fixed it by forcing update to firebase 10.23.0 I changed this file

--- a/node_modules/@react-native-firebase/app/package.json
+++ b/node_modules/@react-native-firebase/app/package.json
@@ -73,7 +73,7 @@
   },
   "sdkVersions": {
     "ios": {
-      "firebase": "10.22.0",
+      "firebase": "10.23.0",
       "iosTarget": "11.0",
       "macosTarget": "10.13"
     },

created a patch file: npx patch-package @react-native-firebase/app --exclude

then updated pod files in ios folder: pod install --repo-update pod update Firebase/Analytics

and rebuilt in root folder: eas build --platform ios --local (i did it locally but I guess it should work with eas cloud build)

Enorme!

I see reference to a gRPC fix in the latest release notes from Google.

However, it still doesn't explain what broke and why it started crashing all of a sudden. Again, makes me think it's an upstream issue.

I'm not a fan of patching packages though.

@rgomezp
Copy link
Author

rgomezp commented Mar 22, 2024

Update: looks like there's a PR open for it: #7699

Edit: I opened a PR with the native package firebase/firebase-ios-sdk#12606

@mikehardy
Copy link
Collaborator

I'll have that PR merged and released probably in the next hour or so @rgomezp, if that helps - your workaround is valid though (patching app/package.json to include the higher SDK version) - there is nothing more to it on our side other than docs and qualifying the release in our e2e testing prior to release

@jeonghoonkim
Copy link

Debug configuration works always fine but release configuration is the problem.
Update version to 10.23.0 does not solve the problem.
image
image

@jeonghoonkim
Copy link

I need to update the build today. I solved this issue by downgrading packages.
For anyone who needs to update their React Native application and has the same issue, here is what I did.

// package.json (19.0.1 -> 18.8.0)
"@react-native-firebase/analytics": "^18.8.0",
"@react-native-firebase/app": "^18.8.0",
"@react-native-firebase/firestore": "^18.8.0",

// ios/Podfile, Add this line.
pod 'BoringSSL-GRPC', '0.0.24'

@rgomezp
Copy link
Author

rgomezp commented Mar 23, 2024

Thanks so much for your work on this @mikehardy

Hmm. I haven't tried this myself, but @jeonghoonkim if that's what works for you then we still need an upstream fix from @mikehardy.

Some folks like myself are using a managed Expo project.

I would also like to understand what exactly happened. Everything was working fine and then just broke. BUT HOW??

@mikehardy
Copy link
Collaborator

Not sure what's going wrong at the native layer - looks like it will be a firebase-ios-sdk fix in the end. But react-native-firebase 19.1.0 is out with latest native at least (firebase-ios-sdk 10.23.0)

@rgomezp
Copy link
Author

rgomezp commented Mar 24, 2024

Tested this myself and can confirm 19.1.0 was not a fix, unfortunately.

@jeonghoonkim , why did you have to revert to 18.8.0?

Also, does anyone know a fix for managed Expo builds?

@jeonghoonkim
Copy link

I read XCode stack traces...
Firebase 19.0.1 depend on higher version of BoringSSL-GRPC. To downgrade the BoringSSL-GRPC version, we have no choice but to downgrade the firebase version as well

@rgomezp
Copy link
Author

rgomezp commented Mar 24, 2024

I read XCode stack traces... Firebase 19.0.1 depend on higher version of BoringSSL-GRPC. To downgrade the BoringSSL-GRPC version, we have no choice but to downgrade the firebase version as well

Thanks for the reply.

Shouldn't that be enough then? Why do we have to also add the GRPC version to the Podfile?

I unfortunately don't have lots of control over the Podfile since I use EAS cloud build under a managed workflow (Expo). I can work around this for now, but I don't want to change my deploy process ideally

@jeonghoonkim
Copy link

jeonghoonkim commented Mar 24, 2024

@rgomezp Yeah I totally agree with you and I really don't want to edit Podfile like this, too.
Downgrading Firebase version from 19.0.1 to 18 does not automatically downgrade the BoringSSL-GRPC version.

Hope for a fix by the package maintainers 😅

@rgomezp
Copy link
Author

rgomezp commented Mar 25, 2024

I found an alternative fix. This might not apply to everyone here but my environment is:

  • Expo 49
  • react-native-firebase (18.8.0 or 19+ it doesn't matter)
  • @react-native-google-signin/google-signin 10.1.1

I upgraded @react-native-google-signin/google-signin to 11.0.0 and the problem went away. However, I had refused to do that prior because of this warning in those release notes.

Raising the target to 13.4 in that podspec doesn't lead to any issues afaict on 49, although I suppose it may not work as expected on some old devices?

Anyway, for anyone experiencing this issue and is using google-signin with Expo 49, give that a shot.

@mikehardy
Copy link
Collaborator

@rgomezp interesting - if google-signin required an upgrade, but react-native-firebase upgraded or not upgraded did not matter, then I wonder if the general issue is inconsistent (or perhaps not-updated / contains an issue) gRPC that's being pinned by google-signin's old version - implying that really getting everything on current versions is the trick

@jeonghoonkim - are you also using other packages that might pull in gRPC and have outdated versions?

@mikehardy
Copy link
Collaborator

Copying this from an issue closed as duplicate to make sure all informative comments are here in one spot, this is from @jillhc on #7697 (comment)


Seeing exactly the same crash in our project, that uses RN Firebase + Expo.

A couple notes to add:

  • This crash only happens on the archived build (archived using Expo and distributed via TestFlight). It does not occur when running locally on device. We tried turning on code optimization and running expo in production mode npx expo start --no-dev --minify , but have been unable to reproduce the crash with those methods.

  • This crash happens upon login or account creation. The original reported mentioned crashing "on startup". I was able to downgrade the build, log out of the Firebase auth account, and then upgrade the build. In the logged out state, the app runs fine! It's only when authenticating that it crashes.

  • Archiving on my computer using Xcode produces as crash-free app! However, it's way more preferable to use Expo for the build process.

@jakechao-zeal have you reported to Expo too? I can share these notes there as well.

@jillhc
Copy link

jillhc commented Mar 25, 2024

Thanks @mikehardy ! I'll also add, the login call is the first Firebase call used in our app, so I'm not positive if the issue is specific to auth or would crash on any interaction with the Firebase backend.

@rgomezp
Copy link
Author

rgomezp commented Mar 25, 2024

I'm seeing the exact same behavior as reported in the other issue. Once you log in, it will always continue crashing on startup. The only way to fix is to delete the app and re-install. Depends on how your login is setup though.

In terms of upgrading Google Sign In, the only changes between those versions is the s.platform field in the podspec. It doesn't seem like that should be enough to cause the crash, but possibly it is. This should at least be a clue to try to figure out what is causing it.

Can others seeing the issue also share your environment?

@fasola81
Copy link

@mikehardy here is our list:
Firebase:
Installing Firebase (10.19.0)
Installing FirebaseABTesting (10.23.0)
Installing FirebaseAnalytics (10.19.0)
Installing FirebaseAppCheckInterop (10.23.0)
Installing FirebaseAuth (10.19.0)
Installing FirebaseAuthInterop (10.23.0)
Installing FirebaseCore (10.19.0)
Installing FirebaseCoreExtension (10.19.0)
Installing FirebaseCoreInternal (10.23.0)
Installing FirebaseCrashlytics (10.19.0)
Installing FirebaseDatabase (10.19.0)
Installing FirebaseFirestore (10.19.0)
Installing FirebaseFirestoreInternal (10.23.0)
Installing FirebaseFunctions (10.19.0)
Installing FirebaseInstallations (10.23.0)
Installing FirebaseMessaging (10.19.0)
Installing FirebaseMessagingInterop (10.23.0)
Installing FirebasePerformance (10.19.0)
Installing FirebaseRemoteConfig (10.23.0)
Installing FirebaseRemoteConfigInterop (10.23.0)
Installing FirebaseSessions (10.23.0)
Installing FirebaseSharedSwift (10.23.0)
Installing FirebaseStorage (10.19.0)
gRPC:
Installing BoringSSL-GRPC (0.0.32)
Installing gRPC-C++ (1.62.1)
Installing gRPC-Core (1.62.1)

@jeonghoonkim
Copy link

@fasola81
You are using
Installing BoringSSL-GRPC (0.0.32)

Try 0.0.24

@fasola81
Copy link

Thanks @jeonghoonkim , We are using Expo and building with EAS, which gives us limited control over native dependencies. I don't believe there's an easy way for us to update those directly within this setup. Does anyone have any information or methods to do this?

@Whaleman0423
Copy link

Whaleman0423 commented Mar 27, 2024

@fasola81 You are using Installing BoringSSL-GRPC (0.0.32)

Try 0.0.24

this is work for me.
I use flutter, and below is my Podfile

#  參考: https://stackoverflow.com/questions/64362285/flutter-on-ios-fatal-error-module-cloud-firestore-not-found
# 因為 podfile 無法獲取到 flutter 所需要的套件, 需要額外更新此份檔案後, 執行 pod install
 platform :ios, '13.0'

 ENV['COCOAPODS_DISABLE_STATS'] = 'true'

 project 'Runner', {

   'Debug' => :debug,
   'Profile' => :release,
   'Release' => :release,
 }

 def flutter_root
   generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
   unless File.exist?(generated_xcode_build_settings_path)
     raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
   end

   File.foreach(generated_xcode_build_settings_path) do |line|
     matches = line.match(/FLUTTER_ROOT\=(.*)/)
     return matches[1].strip if matches
   end
   raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
 end

 require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

 flutter_ios_podfile_setup

 target 'Runner' do
   use_frameworks!
   use_modular_headers!

   # 固定 BoringSSL-GRPC 版本
   pod 'BoringSSL-GRPC', '0.0.24'

   flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
 end

 post_install do |installer|
   installer.pods_project.targets.each do |target|
     flutter_additional_ios_build_settings(target)
   end
 end

@rgomezp
Copy link
Author

rgomezp commented Mar 27, 2024

@fasola81

Thanks , We are using Expo and building with EAS, which gives us limited control over native dependencies. I don't believe there's an easy way for us to update those directly within this setup. Does anyone have any information or methods to do this?

I'm in the same boat. I'm using managed builds with EAS.

I believe the only way we can do this is by ejecting to a bare workflow (remove android and ios directories from gitignore).

Although I think this might be a good opportunity to create a config plugin that does this. I'll see what I can put together.

@rgomezp
Copy link
Author

rgomezp commented Mar 27, 2024

Alright, I've got a solution for managed Expo builds.

https://github.com/rgomezp/expo-pod-pinner

  1. npx expo install expo-pod-pinner
  2. Modify your plugins array in app.config.js or app.json:
"plugins": [
      [
        "expo-pod-pinner",
        {
          "targetName": "StickerSmash",
          "pods": [
            { "BoringSSL-GRPC": "0.0.24" }
          ]
        }
      ]
    ]

Done!

https://dev.to/rgomezp/introducing-expo-pod-pinner-elevate-your-expo-managed-workflow-with-precision-4k67

@fasola81
Copy link

looks spot on, giving it a try. Thanks @rgomezp !

@vethan
Copy link

vethan commented Mar 27, 2024

I might be silly, but I'm getting No target named StickerSmash :(

@fasola81
Copy link

hi @rgomezp, thank you again, Im not clear what a targetName should be, is it an app name or something else? Per your post: Specify the target in your Podfile where the pods should be added.
Can you share more?

@rgomezp
Copy link
Author

rgomezp commented Mar 27, 2024

@fasola81 if you open your Podfile, you should see target <name> do

Normally this is the same as your app name as specified in your app.config.js

@rgomezp
Copy link
Author

rgomezp commented Mar 27, 2024

I might be silly, but I'm getting No target named StickerSmash :(

@vethan, you should use your own target name! 🤣

@vethan
Copy link

vethan commented Mar 27, 2024

I AM SILLY! 🤣 Figured it out after installing the WLS and doing a prebuild! Advice to others: Put the expo-pod-pinner as your last plugin, as at the mo it seems later changes to podfiles might get lost for some reason

@fasola81
Copy link

@rgomezp confirming that your solution worked for us. Thank you all for your help with this.

@rgomezp
Copy link
Author

rgomezp commented Mar 28, 2024

@fasola81

@rgomezp confirming that your solution worked for us. Thank you all for your help with this.

That's awesome to hear! If my new plugin is helpful to you, all I ask is you drop it a star! ⭐

@vethan
Copy link

vethan commented Mar 28, 2024

Cheers @rgomezp ! Works for me although I had problems until I downgraded back to @react-native-firebase version 18.7.3.

@fasola81
Copy link

done, thanks again @rgomezp, really appreciate your help.

@RikuKomiya
Copy link

RikuKomiya commented Mar 28, 2024

I am also using expo's managed workflow and was able to solve this problem using expo-build-properties, so I'll share it with you just in case.

"plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "extraPods": [
              {
                "name": "BoringSSL-GRPC",
                "version": "0.0.24"
              }
            ],
            "useFrameworks": "static"
          }
        }
      ],

https://docs.expo.dev/versions/latest/sdk/build-properties/

@geoffcfchen
Copy link

geoffcfchen commented Mar 30, 2024

Hi everyone, I encountered the same issue but was fortunate enough to find a solution after following a lengthy discussion. Special thanks to @rgomezp @mikehardy for their input!

[
  "expo-pod-pinner",
  {
    "targetName": "Vetcation",
    "pods": [
      { "BoringSSL-GRPC": "0.0.24" }
    ]
  }
]

However, due to Apple's requirement that all apps must upgrade to iOS SDK 17, I had to migrate my project from Expo 49 to Expo 50 after resolving the initial crash issue. Unfortunately, this migration led to a exactly the same crash again. Has anyone else experienced this problem?

Note that I used the following versions for both Expo 49 and Expo 50:

@react-native-firebase/app: "19.0.1"
@react-native-firebase/auth: "19.0.1"
@react-native-firebase/firestore: "19.0.1"
@react-native-firebase/storage: "19.0.1"

Any insights or experiences related to this issue would be greatly appreciated! Thank you!

@geoffcfchen
Copy link

geoffcfchen commented Mar 31, 2024

Hi everyone, I encountered the same issue but was fortunate enough to find a solution after following a lengthy discussion. Special thanks to @rgomezp @mikehardy for their input!

[
  "expo-pod-pinner",
  {
    "targetName": "Vetcation",
    "pods": [
      { "BoringSSL-GRPC": "0.0.24" }
    ]
  }
]

However, due to Apple's requirement that all apps must upgrade to iOS SDK 17, I had to migrate my project from Expo 49 to Expo 50 after resolving the initial crash issue. Unfortunately, this migration led to a exactly the same crash again. Has anyone else experienced this problem?

Note that I used the following versions for both Expo 49 and Expo 50:

@react-native-firebase/app: "19.0.1" @react-native-firebase/auth: "19.0.1" @react-native-firebase/firestore: "19.0.1" @react-native-firebase/storage: "19.0.1"

Any insights or experiences related to this issue would be greatly appreciated! Thank you!

Just to reply to myself and maybe it is useful for others. I found that if I upgrade to Expo 50 and use

    "@react-native-firebase/app": "19.1.1",
    "@react-native-firebase/auth": "19.1.1",
    "@react-native-firebase/firestore": "19.1.1",
    "@react-native-firebase/storage": "19.1.1",

I have to remove expo-pod-pinner plugins array in app.json to successfully execute EAS build and No crash in the Testflight. I think that Expo 50 has fixed the issue. Everything works fine.

@mikehardy
Copy link
Collaborator

Thanks so much for the update!

So if I understand this correctly, it only affects expo and specifically their build services but not local builds (strange but I think that's correct?), and now it appears if using expo 50 and most current version here with no version pins it works?

Would be great to hear this was confirmed by any other affected people...

@vethan
Copy link

vethan commented Mar 31, 2024

I co-incidentally upgraded to expo 50 this week, so tried removing the pod-pinner + upgraded to react-native-firebase 19.1.1 and the crash is gone. This could be related to react native 0.72.x?? Because the crash was happening with people on react native not using expo! Maybe update the requirements to react native 0.73.xx? (For anyone still on 0.72.xx, pinning BoringSSL-GRPC to 0.0.24 and using version 18 of react-native-firebase works as a workaround)

@geoffcfchen
Copy link

geoffcfchen commented Mar 31, 2024

Thanks so much for the update!

So if I understand this correctly, it only affects expo and specifically their build services but not local builds (strange but I think that's correct?), and now it appears if using expo 50 and most current version here with no version pins it works?

Would be great to hear this was confirmed by any other affected people...

Let me share what I had tested (managed Expo project). Hope this is helpful.

  1. Expo 49.0.10 + rn 0.72.1 + @react-native-firebase/app": "18.4.0" + No expo-pod-pinner => EAS build ok, development mode ok, crash on the Testflight
  2. Expo 49.0.10 + rn 0.72.1 + @react-native-firebase/app": "19.1.0" + No expo-pod-pinner => EAS build crash.
  3. (This one works) Expo 49.0.10 + rn 0.72.1 + @react-native-firebase/app": "19.0.1" + with expo-pod-pinner => EAS build ok, development mode ok, Testflight ok.
  4. Expo 50.0.14 + rn 0.73.6 + @react-native-firebase/app": "19.0.1" + with expo-pod-pinner => EAS build ok, development mode ok, crash on the Testflight.
  5. Expo 50.0.14 + rn 0.73.6 + @react-native-firebase/app": "19.1.1" + with expo-pod-pinner => EAS build crash
  6. (This one works) Expo 50.0.14 + rn 0.73.6 + @react-native-firebase/app": "19.1.1" + No expo-pod-pinner => EAS build ok, development mode ok, Testflight ok.

@rgomezp
Copy link
Author

rgomezp commented Apr 13, 2024

@geoffcfchen
Thanks for testing! This is a very strange issue indeed

@mikehardy
Copy link
Collaborator

With apologies - going to close this as not actionable here but what a strange issue
Appears that the general recommendation of "update all the things then retest" will result in a working build in dev, dev mode and TestFlight...

@mikehardy mikehardy added Platform: Expo and removed Impact: Bug New bug report Help: Needs Triage Issue needs additional investigation/triaging. labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests