Skip to content

java.lang.IllegalArgumentException a lot of them being logged in google play console #1830

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

Closed
AbdullahNasim00 opened this issue Jul 29, 2020 · 5 comments
Assignees

Comments

@AbdullahNasim00
Copy link

We have started getting the following exception which is only logged in google play console. Not sure about the exact issue but seems like a bug in FirebaseMessagingService SDK.

java.lang.IllegalArgumentException:
at com.android.okhttp.okio.RealBufferedSource.read (RealBufferedSource.java:53)
at com.android.okhttp.internal.http.Http1xStream$ChunkedSource.read (Http1xStream.java:641)
at com.android.okhttp.internal.Util.skipAll (Util.java:177)
at com.android.okhttp.internal.Util.discard (Util.java:159)
at com.android.okhttp.internal.http.Http1xStream$ChunkedSource.close (Http1xStream.java:674)
at com.android.okhttp.okio.RealBufferedSource.close (RealBufferedSource.java:422)
at com.android.okhttp.okio.RealBufferedSource$1.close (RealBufferedSource.java:410)
at com.google.android.gms.internal.firebase_messaging.zzi.zza
at com.google.firebase.messaging.ImageDownload.close
at com.google.firebase.messaging.DisplayNotification.waitForAndApplyImageDownload
at com.google.firebase.messaging.DisplayNotification.handleNotification
at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage
at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk
at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent
at com.google.firebase.messaging.FirebaseMessagingService.handleIntent
at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService
at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run (Unknown Source:6)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at com.google.android.gms.common.util.concurrent.zza.run (Unknown Source:6)
at java.lang.Thread.run (Thread.java:919)

@google-oss-bot
Copy link
Contributor

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@zwu52
Copy link
Member

zwu52 commented Aug 4, 2020

@AbdullahNasim00 thanks for reporting. Can you let us know what SDK version(s) are seeing this issue?

@AbdullahNasim00
Copy link
Author

AbdullahNasim00 commented Aug 5, 2020

The issue was there till we were using the following SDKs:

implementation 'com.google.firebase:firebase-core:17.4.4'
implementation 'com.google.firebase:firebase-messaging:20.2.3'

In the latest update we have updated the SDKs to:

implementation 'com.google.firebase:firebase-core:17.4.4'
implementation 'com.google.firebase:firebase-messaging:20.2.4'

It's still there in the latest SDK.

We started getting this exception from the time we started adding image to our notification. Hope it helps.

@premacck
Copy link

premacck commented Oct 22, 2020

@AbdullahNasim00 I'm also getting a similar kind of crash whenever sending notifications with images, using firebase messaging 20.3.0, so far it has been observed on various devices running android 9 and 10.

Fatal Exception: java.lang.IllegalArgumentException: byteCount < 0: -901
       at com.android.okhttp.okio.RealBufferedSource.read(RealBufferedSource.java:46)
       at com.android.okhttp.internal.http.Http1xStream$ChunkedSource.read(Http1xStream.java:439)
       at com.android.okhttp.internal.Util.skipAll(Util.java:159)
       at com.android.okhttp.internal.Util.discard(Util.java:141)
       at com.android.okhttp.internal.http.Http1xStream$ChunkedSource.close(Http1xStream.java:472)
       at com.android.okhttp.okio.RealBufferedSource.close(RealBufferedSource.java:396)
       at com.android.okhttp.okio.RealBufferedSource.close(RealBufferedSource.java:396)
       at com.android.okhttp.okio.InflaterSource.close(InflaterSource.java:126)
       at com.android.okhttp.okio.GzipSource.close(GzipSource.java:182)
       at com.android.okhttp.okio.RealBufferedSource.close(RealBufferedSource.java:396)
       at com.android.okhttp.okio.RealBufferedSource$1.close(RealBufferedSource.java:384)
       at com.google.android.gms.internal.firebase_messaging.zzi.zza(zzi.java:4)
       at com.google.firebase.messaging.ImageDownload.close(ImageDownload.java:37)
       at com.google.firebase.messaging.DisplayNotification.waitForAndApplyImageDownload(DisplayNotification.java:53)
       at com.google.firebase.messaging.DisplayNotification.handleNotification(DisplayNotification.java:28)
       at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(FirebaseMessagingService.java:76)
       at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(FirebaseMessagingService.java:55)
       at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(FirebaseMessagingService.java:34)
       at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(FirebaseMessagingService.java:23)
       at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(EnhancedIntentService.java:43)
       at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(EnhancedIntentService.java:6)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at com.google.android.gms.common.util.concurrent.zza.run(zza.java:6)
       at java.lang.Thread.run(Thread.java:764)

One thing I noticed in the stacktrace was this line:
at com.google.firebase.messaging.ImageDownload.close(ImageDownload.java:37)
and I took a look at the close method in ImageDownload class:

    public void close() {
        try {
            zzi.zza(this.connectionInputStream);
        } catch (NullPointerException var2) {
            Log.e("FirebaseMessaging", "Failed to close the image download stream.", var2);
        }
    }

It is only handling NullPointerException and not IllegalArgumentException
@zwu52 is it possible to add a catch block for IllegalArgumentException as well?

In the meanwhile what I've implemented is I've overridden the handleIntent(Intent) method in my class that is extending FirebaseMessagingService like this:

override fun handleIntent(p0: Intent?) {
  try {
    super.handleIntent(p0)
  } catch (e: Exception) {
    Log.e(e)
    // Do something with the intent in case of failure, like showing our own customized notification
  }
}

@zwu52 would this be a good idea?

@gsakakihara gsakakihara assigned gsakakihara and unassigned ciarand and zwu52 Oct 26, 2021
gsakakihara added a commit that referenced this issue Feb 9, 2022
- Switched to stopping an image download by canceling a Future to interrupt the download thread instead of trying to close the InputStream directly since the underlying library does not appear to be thread safe and can throw a variety of Exceptions when close is called on a different thread (#1830 for a previous issue).
gsakakihara added a commit that referenced this issue Feb 9, 2022
- Switched to stopping an image download by canceling a Future to interrupt the download thread instead of trying to close the InputStream directly since the underlying library does not appear to be thread safe and can throw a variety of Exceptions when close is called on a different thread (#1830 for a previous issue).
qdpham13 pushed a commit that referenced this issue Feb 15, 2022
- Switched to stopping an image download by canceling a Future to interrupt the download thread instead of trying to close the InputStream directly since the underlying library does not appear to be thread safe and can throw a variety of Exceptions when close is called on a different thread (#1830 for a previous issue).
jeremyjiang-dev pushed a commit that referenced this issue Mar 9, 2022
- Switched to stopping an image download by canceling a Future to interrupt the download thread instead of trying to close the InputStream directly since the underlying library does not appear to be thread safe and can throw a variety of Exceptions when close is called on a different thread (#1830 for a previous issue).
@gsakakihara
Copy link
Contributor

This should be fixed in the latest version of the SDK.

@firebase firebase locked and limited conversation to collaborators Apr 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants