firebase / firebase-android-sdk

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

Fatal Exception: java.util.NoSuchElementException #2599

Closed appsapiconsole closed 2 years ago

appsapiconsole commented 3 years ago

Environment

Describe the problem

Fatal Exception: java.util.NoSuchElementException at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:75)

   This issue has 143 crash events affecting 131 users

implementation(platform("com.google.firebase:firebase-bom:27.0.0")) implementation("com.google.firebase:firebase-ads") implementation("com.google.firebase:firebase-ml-vision") implementation("com.google.firebase:firebase-config-ktx") implementation("com.google.firebase:firebase-messaging-ktx") implementation("com.google.firebase:firebase-crashlytics-ktx") implementation("com.google.firebase:firebase-analytics-ktx")

//retrofit implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'

0% Background

Android Versions

33% Android 8 30% Android 10 27% Android 9 7% Android 7

Devices: Galaxy A10s Galaxy J7(2016) Galaxy M21 Huawei Y6s Huawei Y7 2019 OPPO CPH1909

Infinix Hot 4 Pro Huawei P30 Pro

Crash on console or Firebase Crashlytics

Fatal Exception: java.util.NoSuchElementException at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:75) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:187) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88) at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:169) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:172) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:929)

Firebase Crashlytics also showing below stack traces with this crash

AdWorker(NG) #1 at sun.misc.Unsafe.park(Unsafe.java) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2109) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092) at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1172) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:929)

Firebase-Messaging-Init at sun.misc.Unsafe.park(Unsafe.java) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:190) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2067) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1120) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092) at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1172) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at com.google.android.gms.common.util.concurrent.zza.run(zza.java:2) at java.lang.Thread.run(Thread.java:929)

PlayBillingLibrary-2 at sun.misc.Unsafe.park(Unsafe.java) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:190) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2067) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092) at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1172) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:929)

google-oss-bot commented 3 years ago

I found a few problems with this issue:

zwu52 commented 3 years ago

FM SDK doesn't take a dependency on okHttp. But as @ciarand points out, we don't declare a dependency on okhttp, but okhttp provides an httpurlconnection impl that the platform uses. see https://android.googlesource.com/platform/external/okhttp/ also https://square.github.io/okhttp/3.x/okhttp-android-support/ so we've gotten bugs w/ okhttp in the stack but it's all the vendor'd version of okhttp and like if the app includes a recent version of okhttp we don't use it So it might be the vendor using the newer buggy version of okhttp under the hood (might be https://github.com/square/okhttp/issues/4875)

In addition, From the stack trace, AdWorker is also spinning a thread. Assuming it's part of firebase-ads. Suggestion to triage to firebase-ads for another look.

appsapiconsole commented 3 years ago

Firebase Crashlytics showing many stack traces along this crash. you can see in attached picture. image

appsapiconsole commented 3 years ago

Every device has different threads along this crash showing AdWorker, CleanupReference, PlayBillingLibrary, FirebaseMessaging-init, Firebase-Installations-executor, com.google.firebase.crashlytics.startup, FirebaseMLHandler, GoogleApiHandler

image image image image

appsapiconsole commented 3 years ago

This issue Related to OkHttp. But I Don't know which firebase component using okhttp effected version. Solution Provided in below stack trace. https://github.com/square/okhttp/issues/5605 Try 3.14.4.

appsapiconsole commented 3 years ago

@ciarand @zwu52 Any update Regarding this issue ?? Any one from Firebase Ads? Which firebase component using okhttp effected version?

mrober commented 3 years ago

There were some known issues with okhttp with some Firebase SDKs that were fixed several versions ago. Please update all your Firebase deps, and let us know if the issue persists.

google-oss-bot commented 2 years ago

Hey @appsapiconsole. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@appsapiconsole if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.