-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Needs Attentionplatform: androidplugin: firestoreFirebase Cloud FirestoreFirebase Cloud Firestoretype: bugNew bug reportNew bug report
Description
onSnapshot does not fire on first launch after fresh installation on some Android devices
After installing the app fresh via Firebase App Distribution, onSnapshot does not fire on certain Android devices when launching the app for the very first time.
The UI stays stuck in a loading state because the snapshot listener never triggers.
Key points:
- Happens only on Android, and only on first launch after fresh install.
- Works correctly on all iOS devices.
- Works correctly on some Android devices.
getDocs()works on all devices, including the affected ones.- If the user kills the app and launches it again, the same affected Android devices work normally β
onSnapshotfires immediately. - Not using Expo.
- Firestore persistence settings are not customized.
- On affected devices,
onSnapshotnever fires even once until the app is killed.
Affected device examples:
- Pixel 9 (Android 15)
- Pixel 6 (Android 12)
(others potentially affected)
Code snippet
const db = getFirestore();
const conversationListRef = query(
collection(db, 'xx'),
where('yyy', 'array-contains', xx),
orderBy('updatedAt', 'desc'),
limit(16),
);
const initialSnap = await getDocs(conversationListRef);
unsubscribe = onSnapshot(
conversationListRef,
{ includeMetadataChanges: true },
(snap: FirebaseFirestoreTypes.QuerySnapshot) => {
// execute logic
}
);
return () => {
if (unsubscribe) {
unsubscribe();
}
};Project Files
Javascript
package.json:
{
"@react-native-async-storage/async-storage": "^2.2.0",
"@react-native-camera-roll/camera-roll": "^7.10.2",
"@react-native-community/datetimepicker": "^8.4.5",
"@react-native-community/netinfo": "^11.4.1",
"@react-native-community/push-notification-ios": "^1.11.0",
"@react-native-firebase/analytics": "^23.4.0",
"@react-native-firebase/app": "^23.4.0",
"@react-native-firebase/auth": "^23.4.0",
"@react-native-firebase/crashlytics": "^23.4.0",
"@react-native-firebase/firestore": "^23.4.0",
"@react-native-firebase/in-app-messaging": "^23.4.0",
"@react-native-firebase/messaging": "^23.4.0",
"react-native": "0.81.5"
}firebase.json
N/A
iOS
Using Pods.
Podfile
N/A
Android
android/build.gradle
import org.apache.tools.ant.taskdefs.condition.Os
buildscript {
ext {
buildToolsVersion = "35.0.0"
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "27.1.12297006"
androidXAnnotation = "1.2.0"
androidXBrowser = "1.3.0"
kotlinVersion = "2.1.20"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("io.sentry:sentry-android-gradle-plugin:5.12.0")
classpath "com.google.gms:google-services:4.4.4"
classpath "com.google.firebase:firebase-crashlytics-gradle:2.9.2"
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
url "$rootDir/../node_modules/detox/Detox-android"
}
}
configurations.all {
resolutionStrategy {
dependencySubstitution { }
}
}
afterEvaluate {
if (tasks.findByName("preBuild")) {
tasks.preBuild.doFirst {
exec {
workingDir rootDir
commandLine './gradlew', 'generateCodegenArtifactsFromSchema'
}
}
println "β app: Will run ./gradlew generateCodegenArtifactsFromSchema before build"
}
}
}android/app/build.gradle
apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "com.facebook.react"
apply plugin: "com.google.gms.google-services"
apply plugin: "com.google.firebase.crashlytics"
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
if (project.env.get("ENV_NAME") == "Production") {
signingConfig signingConfigs.release
} else {
signingConfig signingConfigs.debug
}
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
}
}
}
}AndroidManifest.xml
N/A
Environment
react-native info
System:
OS: macOS 15.5
CPU: (8) arm64 Apple M1
Memory: 137.67 MB / 16.00 GB
... (full details already provided above)
Platform with the issue:
- Android only
react-native-firebase version:
23.4.0
Firebase module with the issue:
@react-native-firebase/firestore
Using TypeScript:
Yes
Metadata
Metadata
Assignees
Labels
Needs Attentionplatform: androidplugin: firestoreFirebase Cloud FirestoreFirebase Cloud Firestoretype: bugNew bug reportNew bug report