urbanairship / android-library

Urban Airship Android SDK
Other
109 stars 123 forks source link

IllegalStateException in FileUtils.downloadFile #211

Closed darrentaft closed 2 years ago

darrentaft commented 2 years ago

❗For how-to inquiries involving Airship functionality or use cases, please contact (support)[https://support.airship.com/].

Preliminary Info

What Airship dependencies are you using?

com.urbanairship.android:urbanairship-fcm:16.7.0 com.urbanairship.android:urbanairship-automation:16.7.0 com.urbanairship.android:urbanairship-message-center:16.7.0

What are the versions of any relevant development tools you are using?

N/A

Report

What unexpected behavior are you seeing?

We're receiving crash reports in our latest app update, which includes 16.7.0 SDK update. Crash signature as follows:

Fatal Exception: java.lang.IllegalStateException: closed
       at com.android.okhttp.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:174)
       at com.android.okhttp.internal.http.HttpEngine$2.read(HttpEngine.java:1042)
       at com.android.okhttp.okio.RealBufferedSource$1.read(RealBufferedSource.java:396)
       at java.io.InputStream.read(InputStream.java:101)
       at com.google.firebase.perf.network.InstrHttpInputStream.read(InstrHttpInputStream.java:146)
       at com.urbanairship.util.FileUtils.downloadFile(FileUtils.java:118)
       at com.urbanairship.iam.assets.AirshipPrepareAssetsDelegate.cacheImage(AirshipPrepareAssetsDelegate.java:95)
       at com.urbanairship.iam.assets.AirshipPrepareAssetsDelegate.onPrepare(AirshipPrepareAssetsDelegate.java:67)
       at com.urbanairship.iam.assets.AssetManager.onPrepare(AssetManager.java:134)
       at com.urbanairship.iam.InAppMessageManager.lambda$onPrepare$0(InAppMessageManager.java:273)
       at com.urbanairship.iam.InAppMessageManager.$r8$lambda$e_s50sPJSrBSOT8m7lo3hKY_khA(InAppMessageManager.java)
       at com.urbanairship.iam.InAppMessageManager$$InternalSyntheticLambda$4$ec305d395c6a9fad134add63d5596ff14c1a56a104c400086100285041831750$0.run(InAppMessageManager.java:8)
       at com.urbanairship.util.RetryingExecutor$ChainedOperations.run(RetryingExecutor.java:205)
       at com.urbanairship.util.RetryingExecutor$1.run(RetryingExecutor.java:126)
       at com.urbanairship.util.SerialExecutor$1.run(SerialExecutor.java:41)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at com.urbanairship.util.AirshipThreadFactory$1.run(AirshipThreadFactory.java:50)
       at java.lang.Thread.run(Thread.java:764)

What is the expected behavior?

No crashes

What are the steps to reproduce the unexpected behavior?

Steps are unknown, however the crashes are mostly occurring within a few seconds of launching the app (and initialising the SDK). Firebase reports that 8% of crashes are when the app was in the background. 100% of crashes are on Samsung devices (many different models). Mostly even split across Android 8, 9, and 10, with small numbers on 7 and 11. No reports from 12 or 13 so far.

Do you have logging for the issue?

jyaganeh commented 2 years ago

Hi @darrentaft, thanks for the report. I'm looking into it.

It looks like something is happening that's causing an IllegalStateException instead of an IOException when attempting to read from a closed stream. We haven't changed the file downloading logic in the SDK in quite some time, so it's not clear to me why that would occur all of a sudden, but it could potentially be related to Firebase Performance instrumentation. In any case, we shouldn't be crashing here and will include a fix to make file downloads more defensive in the next SDK release, later this week.

If you don't mind sharing, what does Firebase report for the number of users impacted?

darrentaft commented 2 years ago

Only 64 crashes for 62 users, between August 5th and 7th. None since, so possibly related to a specific push notification or IAA?

jyaganeh commented 2 years ago

@darrentaft v16.7.1 just went out and includes a change to address this crash. I unfortunately wasn't able to reproduce, but the fact that it seems to be a fleeting issue makes me wonder if it was related to network conditions?