firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.28k stars 579 forks source link

Unable to call firestore from content provider of background app in Android 15 (targetSdk=35) #6419

Open marcardar opened 3 weeks ago

marcardar commented 3 weeks ago

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

Since updating my Pixel 7a to Android 15 (and updating my apps' targetSdkVersion to 35), I've been seeing this in the logs. My app calls the content provider of one of my other apps. The other app (as part of its startup logic) calls firestore.

My working assumption, is that Android 15 has added new restrictions on background apps (i.e. the one with the content provider) accessing the internet. If this is correct, it would be good if the log message better reflected this. Or if there was an appropriate way for the app to first check this restriction before calling firestore.

(25.1.1) [WatchStream]: (b476562) Stream closed with status: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname
    at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223)
    at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282)
    at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at java.lang.Thread.run(Thread.java:1012)
Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname
    at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:124)
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
    at java.net.InetAddress.getAllByName(InetAddress.java:1152)
    at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:632)
    at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219)
    at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) 
    at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
    at java.lang.Thread.run(Thread.java:1012) 
}.
cherylEnkidu commented 3 weeks ago

Hi @marcardar

Thanks for your report! Could you please share more info about this? For example, how long have you noticed this issue happened? Is there any Firebase SDK upgrade in your content provider in the last half year? Do you see it before the content provider upgrading Firestore SDK?

marcardar commented 3 weeks ago

I only started noticing this in the past couple of weeks. Roughly around the time I updated my device to Android 15 and my apps to target Android 15. I frequently update my Firebase SDK version when the stable version is released. In the past month these were when I updated the firestore SDK:

Oct 31: firebase-bom = "33.5.1" Oct 22: firebase-bom = "33.5.0"

I've been using the content provider in this way for over a year. It's not so much that the content provider is causing a problem, but I suspect more that the app is accessing firestore from the background.

cherylEnkidu commented 3 weeks ago

Hi @marcardar , we didn't find any release on Android 15 relates to restriction of background app connectivity issue so far. I will make a note for this, and update you if we have any findings. In the meantime, if you find anything might be related to this issue, please feel free to leave a comment.

marcardar commented 2 weeks ago

What else could be causing it. If I launch the app directly, the log errors do not occur. If the app is accessed via the content provider, then the log errors do occur. This is 100% reproducible on my end. I'm at a loss of what could be causing it.

marcardar commented 2 weeks ago

I noticed that the error also happens straight after the app goes in the background (e.g. after pressing Home). So it's more general than originally thought. i.e. the only reason it was happening when accessing the content provider was because at that moment the app was in the background. So, to reproduce: Launch app (and note no errors from Firestore) then press Android Home, and then we see this in the logs:

 I  Application backgrounded at: timestamp_millis: 1731076358815
 V  Read error: ssl=0xb400007a99a2d558: I/O error during system call, Software caused connection abort
 V  Write error: ssl=0xb400007a99a2d558: I/O error during system call, Broken pipe
 D  tagSocket(5) with statsTag=0xffffffff, statsUid=-1
 V  SSL shutdown failed: ssl=0xb400007a99a2d558: I/O error during system call, Success
 W  (25.1.1) [WatchStream]: (477e11e) Stream closed with status: Status{code=UNAVAILABLE, description=End of stream or IOException, cause=null}.
<truncated>
UnicornaasTech commented 2 weeks ago

I'm experiencing the same issue - albeit only tested so far in emulator environment. I'm running Pixel 7 API 35, inside Android Studio. I get the error when when the app is in the background and the app receives a push notification which has an image link.

romaopedro commented 7 hours ago

Here I have a Pixel 8 with Android 15. In my case, I put the app in the background and I have a worker running after some time. I always get the same error.