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

🔥 Functions crash in IOS Release Mode only #8369

Open
1 of 9 tasks
PL47productions opened this issue Feb 24, 2025 · 2 comments · May be fixed by #8371
Open
1 of 9 tasks

🔥 Functions crash in IOS Release Mode only #8369

PL47productions opened this issue Feb 24, 2025 · 2 comments · May be fixed by #8371
Labels
impact: crash Behaviour causing app to crash. Needs Attention platform: ios plugin: functions Firebase Cloud Functions type: bug New bug report

Comments

@PL47productions
Copy link

Issue

Describe your issue here
In my IOS project, when making a call to firebase functions in Release mode, I am encountering -[NSNull length]: unrecognized selector error.

Interestingly, the call works fine when running in Debug mode on IOS. On Android, everything works correctly in both Debug and Release modes. I'll also note that authorization calls and calls to firestore work fine in both release and debug mode for both platforms.

In the "JavaScript" section of the provided bug reporting template, I included the simple function call that is triggering the error.

The crash logs do not provide a lot of detail and I have spent numerous hours trying to figure out what is happening, with no luck.

The only error I receive:
"libc++abi: terminating due to uncaught exception of type facebook::jsi::JSError: Exception in HostFunction: -[NSNull length]: unrecognized selector sent to instance 0x1e4877140

Error: Exception in HostFunction: -[NSNull length]: unrecognized selector sent to instance 0x1e4877140"

Additionally, Xcode indicates the (red) X next to Thread 2 Queue : com.meta.react.turbomodulemanager.queue (serial)

The crash logs do not point to any particular line, but I did see that within the functions library/pod, the Functions file on line 486 the does point to an NSNull() variable:
let data = data ?? NSNull()

Just a wild guess at this point, no idea. Please advise, thanks.


Project Files

Javascript

export async function getFastFinAccountsHelper(id){ try{
  let retrieveBalances = functions().httpsCallable('getAccounts');      
  let finAccountsArray = await retrieveBalances({customerId: id}).then(function(result) {
    return result.data.accounts;
  }).catch(() => {
    return []
  })

  return finAccountsArray;

 
}catch(e){
  uploadError(e.message)
}

}

package.json:

# N/A

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 Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, min_ios_version_supported
prepare_react_native_project!

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

target 'budgeteven' do
  config = use_native_modules!
  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true

  use_react_native!(
    :path => config[:reactNativePath],
  
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )
  end
end

AppDelegate.m:

import UIKit
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
import FirebaseCore



@main
class AppDelegate: RCTAppDelegate {
  override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    self.moduleName = "budgeteven"
    self.dependencyProvider = RCTAppDependencyProvider()
    FirebaseApp.configure()
    // 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)
  }

  override func sourceURL(for bridge: RCTBridge) -> URL? {
    self.bundleURL()
  }

  override func bundleURL() -> URL? {
#if DEBUG
    RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
    Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
  }
}


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

System:
  OS: macOS 15.3.1
  CPU: (12) x64 Apple M2 Max
  Memory: 329.85 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.17.1
    path: /usr/local/bin/node
  Yarn: Not Found
  npm:
    version: 9.6.7
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23726.103.2422.13016713
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.1
    wanted: 0.77.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
  • 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:
    • e.g. 21.11.0
  • Firebase module(s) you're using that has the issue:
    • @react-native-firebase/functions
  • Are you using TypeScript?
    • N


@mikehardy
Copy link
Collaborator

mikehardy commented Feb 24, 2025

Hey 👋 ! I've got good news and bad news - good news first. Lucky winner, this crash doesn't have a lot of information but I reproduce it immediately in our test harness! (this is a rare thing, and usually the hardest part of the triage effort)

    functions() modular
      firebase v8 compatibility
18:51:15.477 detox[62763] i 
 �] Jet client disconnected - for no particular reason (code = 1006).
[�] Exiting after an abnormal disconnect.
 error: The app has crashed, see the details below:
  
  Exception in HostFunction: -[NSNull length]: unrecognized selector sent to instance 0x1e3a77a80
  
  Error: Exception in HostFunction: -[NSNull length]: unrecognized selector sent to instance 0x1e3a77a80
  (
        0   Detox                               0x000000010318a514 +[NSThread(DetoxUtils) dtx_demangledCallStackSymbols] + 36
        1   Detox                               0x000000010318d520 __DTXHandleCrash + 668
        2   Detox                               0x000000010318e048 __dtx_terminate() + 376
        3   libc++abi.dylib                     0x00000001802ac4d8 std::__terminate(void (*)()) + 12
        4   libc++abi.dylib                     0x00000001802ac488 std::terminate() + 52
        5   libdispatch.dylib                   0x000000018017cc1c _dispatch_client_callout + 36
        6   libdispatch.dylib                   0x0000000180184da0 _dispatch_lane_serial_drain + 976
        7   libdispatch.dylib                   0x0000000180185924 _dispatch_lane_invoke + 388
        8   libdispatch.dylib                   0x0000000180191038 _dispatch_root_queue_drain_deferred_wlh + 276
        9   libdispatch.dylib                   0x0000000180190694 _dispatch_workloop_worker_thread + 440
        10  libsystem_pthread.dylib             0x0000000103327b74 _pthread_wqthread + 284
        11  libsystem_pthread.dylib             0x0000000103326934 start_wqthread + 8
  )

bad news is, yes, there is some sort of unexpected crash in iOS release mode - obviously we test debug mode in our day to day so we never saw this.

I'm going to open a PR tagged to close this bug but please understand all it is doing is setting up our e2e test harness to allow for release builds + runs, it did not before. No fix yet unfortunately

@mikehardy mikehardy added platform: ios plugin: functions Firebase Cloud Functions impact: crash Behaviour causing app to crash. labels Feb 24, 2025
@mikehardy mikehardy linked a pull request Feb 25, 2025 that will close this issue
9 tasks
@PL47productions
Copy link
Author

Thanks for the good news lol!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact: crash Behaviour causing app to crash. Needs Attention platform: ios plugin: functions Firebase Cloud Functions type: bug New bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants