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 ultra slow writes after upgrade on Android (App 8.2.0 -> 8.4.1 & Firestore 7.4.3 -> 7.7.0) #4189

Closed
5 of 10 tasks
eric-edouard opened this issue Sep 1, 2020 · 21 comments
Labels
blocked: firebase-sdk Pending a confirmed fix landing on the official native sdk's (iOS/Android). platform: android plugin: firestore Firebase Cloud Firestore type: bug New bug report

Comments

@eric-edouard
Copy link

Issue

Hi, we have encountered a bug on the latest version of Firestore which makes write operations (specifically updates) very slow (up to 40 seconds). This seems to happen only on Android, with the Firestore's set() and update() functions.

After many hours of debugging, it turns out that downgrading back to our previous version all our RNFirebase packages by setting fixed versions (removing the ^) solved the issue.

We do not know on which version specifically the bug started.

Do not hesitate if you need any more information

Project Files

Javascript

Click To Expand

package.json:

{
	"name": "ballon",
	"version": "0.0.1",
	"private": true,
	"scripts": {
		"android": "cd android && ./gradlew clean && cd .. && react-native run-android",
		"ios": "react-native run-ios",
		"start": "react-native start",
		"test": "jest",
		"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
		"pretty": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
		"deploy": "yarn deploy:rules && yarn deploy:functions",
		"deploy:rules": "yarn deploy:rules:storage && yarn deploy:rules:firestore && yarn deploy:rules:database",
		"deploy:rules:storage": "firebase deploy --only storage:rules",
		"deploy:rules:database": "firebase deploy --only database:rules",
		"deploy:rules:firestore": "firebase deploy --only firestore:rules",
		"deploy:functions": "cd src/services/functions && yarn deploy"
	},
	"dependencies": {
		"@expo/react-native-action-sheet": "^3.8.0",
		"@invertase/react-native-apple-authentication": "^1.1.2",
		"@react-native-community/async-storage": "^1.11.0",
		"@react-native-community/masked-view": "^0.1.10",
		"@react-native-community/netinfo": "^5.9.5",
		"@react-native-community/push-notification-ios": "^1.4.1",
		"@react-native-community/segmented-control": "^2.1.0",
		"@react-native-firebase/app": "^8.2.0",
		"@react-native-firebase/auth": "^8.2.0",
		"@react-native-firebase/crashlytics": "^8.1.2",
		"@react-native-firebase/database": "^7.3.2",
		"@react-native-firebase/firestore": "^7.4.3",
		"@react-native-firebase/functions": "^7.3.1",
		"@react-native-firebase/messaging": "^7.7.2",
		"@react-native-firebase/remote-config": "^8.1.1",
		"@react-native-firebase/storage": "^7.2.2",
		"@react-navigation/native": "^5.7.1",
		"@react-navigation/stack": "^5.7.1",
		"@types/chroma-js": "^2.0.0",
		"@types/js-levenshtein": "^1.1.0",
		"@types/lodash.clonedeep": "^4.5.6",
		"@types/lodash.isarray": "^4.0.6",
		"@types/lodash.isequal": "^4.5.5",
		"@types/lodash.isobject": "^3.0.6",
		"@types/lodash.transform": "^4.6.6",
		"@types/react-native-fbsdk": "^1.1.0",
		"@types/react-native-push-notification": "^5.0.0",
		"@types/react-native-uuid": "^1.4.0",
		"@types/react-native-vector-icons": "^6.4.5",
		"add": "^2.0.6",
		"chroma-js": "^2.1.0",
		"easy-peasy": "^3.3.1",
		"husky": "^4.2.5",
		"js-levenshtein": "^1.1.6",
		"lodash.clonedeep": "^4.5.0",
		"lodash.isarray": "^4.0.0",
		"lodash.isequal": "^4.5.0",
		"lodash.isobject": "^3.0.2",
		"lodash.transform": "^4.6.0",
		"pretty-quick": "^2.0.1",
		"react": "^16.13.1",
		"react-native": "^0.63.2",
		"react-native-cardview": "^2.0.5",
		"react-native-charts-wrapper": "^0.5.7",
		"react-native-device-time-format": "^2.3.0",
		"react-native-fast-image": "^8.3.2",
		"react-native-fbsdk": "^2.0.0",
		"react-native-gesture-handler": "^1.7.0",
		"react-native-image-crop-picker": "^0.32.2",
		"react-native-image-picker": "^2.3.3",
		"react-native-in-app-message": "^1.0.32",
		"react-native-linear-gradient": "^2.5.6",
		"react-native-modalize": "^2.0.5",
		"react-native-portalize": "^1.0.7",
		"react-native-push-notification": "^5.0.1",
		"react-native-reanimated": "^1.10.1",
		"react-native-safe-area-context": "^3.1.1",
		"react-native-screens": "^2.9.0",
		"react-native-segmented-control-tab": "^3.4.1",
		"react-native-splash-screen": "^3.2.0",
		"react-native-svg": "^12.1.0",
		"react-native-uuid": "^1.4.9",
		"react-native-vector-icons": "^7.0.0",
		"yarn": "^1.22.4"
	},
	"devDependencies": {
		"@babel/core": "^7.8.4",
		"@babel/runtime": "^7.11.2",
		"@firebase/testing": "^0.20.9",
		"@react-native-community/eslint-config": "^1.1.0",
		"@types/chalk": "^2.2.0",
		"@types/chance": "^1.1.0",
		"@types/columnify": "^1.5.0",
		"@types/jest": "^25.2.3",
		"@types/lodash.pick": "^4.4.6",
		"@types/react-native": "^0.63.1",
		"@types/react-test-renderer": "^16.9.2",
		"@typescript-eslint/eslint-plugin": "^2.27.0",
		"@typescript-eslint/parser": "^2.27.0",
		"babel-jest": "^25.1.0",
		"chalk": "^4.1.0",
		"chance": "^1.1.6",
		"columnify": "^1.5.4",
		"eslint": "^6.5.1",
		"eslint-config-prettier": "^6.11.0",
		"eslint-plugin-prettier": "^3.1.4",
		"firebase-admin": "^9.0.0",
		"firebase-functions-test": "^0.2.1",
		"firebase-tools": "^8.6.0",
		"jest": "^26.2.2",
		"js-base64": "^3.4.5",
		"lodash.pick": "^4.4.0",
		"metro-react-native-babel-preset": "^0.59.0",
		"prettier": "^2.0.4",
		"react-native-svg-transformer": "^0.14.3",
		"react-test-renderer": "16.13.1",
		"ts-jest": "^26.1.4",
		"typescript": "^3.8.3"
	},
	"husky": {
		"hooks": {
			"pre-commit": "pretty-quick --staged"
		}
	},
	"jest": {
		"preset": "react-native",
		"moduleFileExtensions": [
			"ts",
			"tsx",
			"js",
			"jsx",
			"json",
			"node"
		]
	}
}

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:
# N/A

AppDelegate.m:

// N/A


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:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
        classpath("com.google.gms:google-services:4.2.0")
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.0.0")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://maven.google.com' }
        maven { url 'https://www.jitpack.io' }
    }
}

android/app/build.gradle:

apply plugin: "com.android.application"
apply plugin: "com.google.gms.google-services"
apply plugin: "com.google.firebase.crashlytics"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation. If none specified and
 *   // "index.android.js" exists, it will be used. Otherwise "index.js" is
 *   // default. Can be overridden with ENTRY_FILE environment variable.
 *   entryFile: "index.android.js",
 *
 *   // https://reactnative.dev/docs/performance#enable-the-ram-format
 *   bundleCommand: "ram-bundle",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    enableHermes: false,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.laforge.ballon"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            
            /* Add the firebaseCrashlytics extension (by default,
            * it's disabled to improve build speeds) and set
            * nativeSymbolUploadEnabled to true. */

            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
            }
        }
    }

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation project(':react-native-svg')
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
    
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
    
    implementation 'androidx.multidex:multidex:2.0.1'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

android/settings.gradle:

rootProject.name = 'ballon'
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')

MainApplication.java:

package com.laforge.ballon;

import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import androidx.multidex.MultiDexApplication;
import com.horcrux.svg.SvgPackage;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;

public class MainApplication extends MultiDexApplication implements ReactApplication {

  private final ReactNativeHost mReactNativeHost =
      new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
          return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          return packages;
        }

        @Override
        protected String getJSMainModuleName() {
          return "index";
        }
      };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
    FacebookSdk.sdkInitialize(getApplicationContext());
    AppEventsLogger.activateApp(this);
  }

  /**
   * Loads Flipper in React Native templates. Call this in the onCreate method with something like
   * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
   *
   * @param context
   * @param reactInstanceManager
   */
  private static void initializeFlipper(
      Context context, ReactInstanceManager reactInstanceManager) {
    if (BuildConfig.DEBUG) {
      try {
        /*
         We use reflection here to pick up the class that initializes Flipper,
        since Flipper library is not available in release mode
        */
        Class<?> aClass = Class.forName("com.laforge.ballon.ReactNativeFlipper");
        aClass
            .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
            .invoke(null, context, reactInstanceManager);
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (NoSuchMethodException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      }
    }
  }
}

AndroidManifest.xml:

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.laforge.ballon">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:requestLegacyExternalStorage="true"
      android:theme="@style/AppTheme">
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
        <activity
          android:name=".SplashActivity"
          android:theme="@style/SplashTheme"
          android:label="@string/app_name">
          <intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
        </activity>
        <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan"
        android:exported="true">
        </activity>
        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
        <meta-data  android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_notification" />
    </application>
</manifest>


Environment

react-native info output:

System:
    OS: macOS 10.15.5
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 265.00 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.13.0 - /usr/local/bin/node
    Yarn: 1.19.2 - /usr/local/bin/yarn
    npm: 6.12.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 26, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-29 | Google APIs Intel x86 Atom, android-R | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.6/11E708 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_221 - /usr/bin/javac
    Python: 3.8.3 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^16.13.1 => 16.13.1 
    react-native: ^0.63.2 => 0.63.2 
  npmGlobalPackages:
    *react-native*: Not Found
  • 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:
    • ^8.2.0
  • Firebase module(s) you're using that has the issue:
    • e.g. Instance ID
  • Are you using TypeScript?
    • Y


@eric-edouard eric-edouard added help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report labels Sep 1, 2020
@mikehardy
Copy link
Collaborator

@react-native-firebase/app 8.4.1 includes firebase-bom 25.7.0: https://github.com/invertase/react-native-apple-authentication/
@react-native-firebase/app 8.3.1 includes firebase-bom 25.5.0 https://github.com/invertase/react-native-firebase/blame/6890d68cf9bd7b940aca5c502977177c9a9c569f/packages/app/package.json

Before that (down to 8.2.0 the firebase-bom was 25.3.1

My advice: Upgrade back to current stable versions of react-native-firebase, you want those bug fixes.

Override your firebase-bom https://rnfirebase.io/#android to 25.3.1 and re-test.

My hypothesis is you will not reproduce your performance problem - this should be a "negative test", and if your performance is fine, it means react-native-firebase is fine but there is a problem somewhere between version 25.3.1 and 25.7.0 of the firebase-android-sdk bill of materials versions.

Then you will want to "bisect" between those firebase-android-sdk versions to see where the problem starts, and check their release notes and active issues to see what's going on upstream.

If my hypothesis is wrong, if you update react-native-firebase back to current stable versions, but override the firebase-android-sdk down to 25.3.1 and you still reproduce the problem, then the problem is here and we will bisect the changes here while pinning the bill of materials to 25.3.1.

Please let us know what you find

@mikehardy mikehardy added platform: android plugin: firestore Firebase Cloud Firestore Workflow: Waiting for User Response Blocked waiting for user response. labels Sep 1, 2020
@eric-edouard
Copy link
Author

eric-edouard commented Sep 2, 2020

Hello, thanks for the quick reply.

Indeed you were right, we have found that the issue comes from firebase-bom.
The bug is solved when using the last versions of RNFirebase and downgrading firebase-bom to 25.5.0.

More specifically, I believe the bug started with Firebase BoM 25.6.0 (which includes firestore 21.5.0), an issue on the android-sdk #1906 seems to be describing a very similar problem which should be fixed with future updates.

@mikehardy
Copy link
Collaborator

Well I'm glad you've got at least a temporary solution @ericedouard and thanks for a bunch for following up and linking the related issue, that will help others that aren't sure where the problem is if they are hit with this

@mikehardy mikehardy added blocked: firebase-sdk Pending a confirmed fix landing on the official native sdk's (iOS/Android). Resolution: Solution Provided and removed help: needs-triage Issue needs additional investigation/triaging. Workflow: Waiting for User Response Blocked waiting for user response. labels Sep 2, 2020
@pmakwanaPresentation
Copy link

Hello,
I am facing the same slow api call issue in android only,
Before using react-native-firebase v6, we were using firebase package and our api call was finishing within 4-5 sec, but after using react native-firebase v6, it is taking 15 to 20 sec to fetch data and loading at UI with the same code.

I also tried the above solution like using the latest versions for all firebase libs and overriding the BOM version to 25.3.1, but it's not helping.

Could any one please guide me on this?

Thanks in advance!

@mikehardy
Copy link
Collaborator

@pmakwanaPresentation please open a new issue following the template carefully, the original issue here is solved (or at least has a workaround). For your case also make sure that you have done npx react-native-clean-project so you know you are using the correct code, and make absolutely sure the BOM version from the gradle plugin is correct so you know the override is working.

@Patzelly
Copy link

Patzelly commented Sep 4, 2020

We have the same issue, can you tell us to downgrad only firebase-bom @eric-edouard

@mikehardy
Copy link
Collaborator

@Patzelly https://rnfirebase.io/#android example https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh#L39

@ScreamZ
Copy link
Contributor

ScreamZ commented Sep 22, 2020

Looks like firebase/firebase-android-sdk#1906 is fixed, could we get a patch on RNF ?

@Patzelly
Copy link

Hi @ScreamZ, is Firestore slow for you in Android ?

@ScreamZ
Copy link
Contributor

ScreamZ commented Sep 22, 2020

It is, I didn't gave a try to the hacky patch solution above yet

@Patzelly
Copy link

Same for us, and the hacky solution doesn't work for us

@mikehardy
Copy link
Collaborator

@ScreamZ we are not in control of the firebase-android-sdk release schedule and in fact have no influence on it. You will have to wait until the next release. Here is the definitive information on release status for that patch:

firebase/firebase-android-sdk#1971 (comment)

We submitted a fix (#1920) essentially just after the freeze for the last release so it didn't make it into 21.6.0. This fix should go out with the upcoming release. Any version prior to 21.5.0 should be unaffected.

It appears an older BOM may be used to try resolving your issue by moving to a version of firestore prior to 21.5.0, https://firebase.google.com/support/release-notes/android#bom_v25-4-1

Override the BOM to get the version like so: https://rnfirebase.io/#android / https://github.com/mikehardy/rnfbdemo/blob/9e80bacc9b62961f89246eea82dd956f4f8660f8/make-demo.sh#L39

This of course may have other side effects as you are going downwards in versions but it may help you.

@ahanusek
Copy link

ahanusek commented Oct 1, 2020

Hello, thanks for the quick reply.

Indeed you were right, we have found that the issue comes from firebase-bom.
The bug is solved when using the last versions of RNFirebase and downgrading firebase-bom to 25.5.0.

More specifically, I believe the bug started with Firebase BoM 25.6.0 (which includes firestore 21.5.0), an issue on the android-sdk #1906 seems to be describing a very similar problem which should be fixed with future updates.

@eric-edouard

The Latest Firebase BoM 25.11.0 (release 30.09) works properly with the latest RNF packages. Can you check this version in your project?

@MujtabaFR
Copy link
Contributor

Looks like that Firestore release 21.6.0 has solved this issue .. This release is included in Firebase BoM 25.10.0

I think that RNfirebase team should update their libraries to fix this important issue

As a side fix .. try to override BoM version in your /android/app/build.gradle to 25.10.0 or higher

@mikehardy
Copy link
Collaborator

@MujtabaFR we typically don't do version releases just to bump the underlying SDK versions, we normally only bump those when we rely on underlying APIs that were added thus requiring the bump. The override is there for this exact reason and will be the way to access higher performance firestore writes for those that need it probably for a while as I don't think there are any other PRs requiring new APIs from that BoM version

@MujtabaFR
Copy link
Contributor

MujtabaFR commented Oct 13, 2020

You're correct @mikehardy, users can override the SDK Versions according to their needs.

But normally every user of RNfirebase follows your updates without overriding.. so every app will have this sever issue (the app will become useless if connection to firestore failed)
It caused too much troubles for my users.. lost their trust and got too many bad reviews
It shouldn't happen in the first place if you've updated the libraries as soon as firebase fixed the issue

sorry for the long comment, But in my opinion, this is a sever issue that needs a release to bump the underlying SDK version

@mikehardy
Copy link
Collaborator

@MujtabaFR I look forward to your PR implementing the same, it should pass tests here, we can merge it

@MujtabaFR
Copy link
Contributor

MujtabaFR commented Oct 15, 2020

Worth mentioning that many of my users still have connection failure to firestore despite of overriding Firebase BoM to 25.12.0

Update 1:

looks like the overriding feature is not working for me.. I'm getting the same old BoM version

Update 2:

the overriding code needs to be in the /android/build.gradle file to work, not in /android/app/build.gradle as mentioned in the docs

@mikehardy
Copy link
Collaborator

I don't believe connection failure will be resolved by anything other than a more stable network? I still need to work through whatever is causing the android build failure in our CI E2E tests, but I will note I'm using the 25.12.0 BoM successfully in my work project

mikehardy pushed a commit to mikehardy/react-native-firebase that referenced this issue Oct 16, 2020
Upgrade firebase sdk version to 25.12.0 to fix [issue invertase#4189](invertase#4189)
mikehardy pushed a commit to mikehardy/react-native-firebase that referenced this issue Oct 16, 2020
Upgrade firebase sdk version to 25.12.0 to fix [issue invertase#4189](invertase#4189)
mikehardy added a commit that referenced this issue Oct 16, 2020
* Upgrade firebase sdk version

Upgrade firebase sdk version to 25.12.0 to fix [issue #4189](#4189)

* Update iid android library

Co-authored-by: Mike Hardy <[email protected]>

* update sdk for ios firebase, iid and playServicesAuth
* update firebase bom version
* Update FirebaseSDKVersion
* Install firebase-tools as dev dep in tests, reference locally
* De-integrate pre-compiled firestore, incompatible with Xcode12+detox

invertase/firestore-ios-sdk-frameworks#15

* Exclude arm64/i386 from simulator build archs for Xcode12 compatibility

Without these, there are linker failures as Xcode12 attempts to build for
all archs, even when it's not really possible

* Workaround upstream MLKit dependency-related compile failures

https://firebase.google.com/support/release-notes/android#mlkit-self-serve-fixes
firebase/firebase-android-sdk#1904

* Use Xcode "latest-stable" (12 now) in E2E CI

This should fix #4397

Co-authored-by: Mujtaba F. Radhi <[email protected]>
androidIsForVivek pushed a commit to androidIsForVivek/react-native-firebase that referenced this issue Aug 9, 2021
…rtase#4401)

* Upgrade firebase sdk version

Upgrade firebase sdk version to 25.12.0 to fix [issue invertase#4189](invertase#4189)

* Update iid android library

Co-authored-by: Mike Hardy <[email protected]>

* update sdk for ios firebase, iid and playServicesAuth
* update firebase bom version
* Update FirebaseSDKVersion
* Install firebase-tools as dev dep in tests, reference locally
* De-integrate pre-compiled firestore, incompatible with Xcode12+detox

invertase/firestore-ios-sdk-frameworks#15

* Exclude arm64/i386 from simulator build archs for Xcode12 compatibility

Without these, there are linker failures as Xcode12 attempts to build for
all archs, even when it's not really possible

* Workaround upstream MLKit dependency-related compile failures

https://firebase.google.com/support/release-notes/android#mlkit-self-serve-fixes
firebase/firebase-android-sdk#1904

* Use Xcode "latest-stable" (12 now) in E2E CI

This should fix invertase#4397

Co-authored-by: Mujtaba F. Radhi <[email protected]>
@felix-lambert
Copy link

Any updates?

@mikehardy
Copy link
Collaborator

There should be no expectation for any updates on closed issues, especially year old ones. If you can reproduce on current stable versions please open a new issue, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: firebase-sdk Pending a confirmed fix landing on the official native sdk's (iOS/Android). platform: android plugin: firestore Firebase Cloud Firestore type: bug New bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants