Navigation Menu

Skip to content
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

Firebase Push Notifications NPE #709

Closed
rayliverified opened this issue Aug 14, 2019 · 34 comments
Closed

Firebase Push Notifications NPE #709

rayliverified opened this issue Aug 14, 2019 · 34 comments

Comments

@rayliverified
Copy link

I'm getting 100s of NPEs from sending push notifications. My suspicion is that it has something to do with the image push notifications that Firebase now supports.
These crashes don't seem to be user facing which is good. Unfortunately, Google counts crashes in app store rankings so I'm scared about the amount of crashes I'm getting.

Here's the crash logs:

java.lang.NullPointerException: 
  at com.android.okhttp.okio.Buffer.write (Buffer.java:1182)
  at com.android.okhttp.okio.Buffer.read (Buffer.java:1221)
  at com.android.okhttp.okio.RealBufferedSource.read (RealBufferedSource.java:65)
  at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.read (Http1xStream.java:602)
  at com.android.okhttp.internal.Util.skipAll (Util.java:172)
  at com.android.okhttp.internal.Util.discard (Util.java:154)
  at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.close (Http1xStream.java:619)
  at com.android.okhttp.okio.RealBufferedSource.close (RealBufferedSource.java:421)
  at com.android.okhttp.okio.RealBufferedSource$1.close (RealBufferedSource.java:409)
  at com.google.android.gms.internal.firebase_messaging.zzk.zza
  at com.google.firebase.messaging.zzi.close
  at com.google.firebase.messaging.zzb.zza
  at com.google.firebase.messaging.FirebaseMessagingService.zzc
  at com.google.firebase.messaging.zzg.run
  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:764)

This error occurs on a range of devices.

I'm sending the notifications from the Firebase console and using the latest Firebase Messaging SDK v19.0.1

@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.

@hariiprasad
Copy link

@searchy2 i am also facing exactly same issue

@BlackHei
Copy link

I am also facing this issue, any clue?

@ciarand
Copy link
Contributor

ciarand commented Aug 19, 2019

Hey folks, thanks for reporting this. Some followup questions:

  • @searchy2 do you have a proguard map for the above stack? It looks like it might have been proguarded twice, so it's difficult to tell exactly where the failure is coming from
  • @ everyone else: you're using the new image support, right? what sort of image types / sizes / etc. are you using? are these being uploaded via the console or are you referencing files that are hosted elsewhere?

@hariiprasad
Copy link

hey @ciarand in My case the image format is jpg and i am just referencing that files from github( i placed the push Notification images in my github) .

@rayliverified
Copy link
Author

The images I've used are all PNGs uploaded to Firebase Storage.

There is no Proguard active in my app and any obfuscation is probably done by the Firebase SDK itself. The error log looks readable to me and I've seen it in other places on the internet.

@duncancarroll
Copy link

duncancarroll commented Aug 27, 2019

@ciarand What new image support are you referring to? I encounter this with most notifications that include images. Some of these images can be large-ish, so it's possible they are running into some time limit on decode / download (I think I saw a logcat message re: that locally.) If I have time I'll try reproducing it with a curl and report back.

When we decode these on the app side with the data {} payload, this error never occurs, it's only when the OS attempts to parse the notification {} body on it's own.

Re: obfuscation, it's not being double-proguarded, that's the lib itself's proguarding.

OP left out the message which is:

Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'int com.android.okhttp.okio.Segment.limit' on a null object reference

@turgayulutas
Copy link

@searchy2 did you find a solution?

@BlackHei
Copy link

anyone have solution?

@turgayulutas
Copy link

@BlackHei , I've been sending .gif with notification. I've canceled gif posting and I'm only sending .png and .jpeg notifications. I'm not sure, but since I stopped sending .gif, there was no error.

@littleariel
Copy link

We're seeing the same issue on our side, with images in push notifications. The images are hosted by a 3rd party service.

@IevgenOsetrov
Copy link

We solved this by reducing the image sizes, unfortunately firebase not handles large images

@littleariel
Copy link

@osjack thanks for the info! Anything you could share regarding the max size that seems to work? Is it a kb size or resolution limitation?

@vedprakashwagh
Copy link

vedprakashwagh commented Sep 13, 2019

Yeah I've been having this issue lately, I googled the problem but couldn't find any solution. I've added question on StackOverflow regarding this issue. I've already added reducing image size as a possible solution, if you have anything that worked for you, I'll be glad to add it.
Here's the question: https://stackoverflow.com/questions/57893795/nullpointerexception-only-on-very-very-few-devices-after-sending-push-notificati/57918864#57918864

@IevgenOsetrov
Copy link

IevgenOsetrov commented Sep 13, 2019

@littleariel I think its actual image size in kb, we reduced the width to 200px and height proportionally and it solved the problem

@littleariel
Copy link

@osjack thanks! We'll keep that in mind if we decide to use images again, but will probably hold off until this is resolved on the Firebase SDK side.

@rayliverified
Copy link
Author

rayliverified commented Sep 26, 2019

Obfuscated code is not fun to dig through but I think I've pinpointed the cause of the problem.

Working backwards through the stacktrace...
com.google.android.gms.internal.firebase_messaging.zzk.zza - Google's logging class to catch InputStream exceptions. My best guess is that close is being called on a null InputStream and that's the cause of the crash. IOException doesn't catch null exceptions.
MaxthonSnap20190926103305

Now why would the InputStream be null?
com.google.firebase.messaging.zzi.close, com.google.firebase.messaging.zzb.zza - Firebase's Executor and Task used to return Bitmap to FirebaseMessagingService. The actual decoding of the input stream is a bit unclear and might be unrelated. The crash originates inside the Executor here.
MaxthonSnap20190926104635

com.google.firebase.messaging.FirebaseMessagingService.zzc - this function is the culprit. My guess is that a 5 second timeout forces close to be called on a null InputStream.
MaxthonSnap20190926104324

Mystery solved? 🤞 My takeaway is to make your image small enough to be downloadable in 5 seconds. Or else your push notifications might not have images :(

Another fascinating gem, the maximum size of an image is 1048576 bytes or approximately 1MB. Should probably be documented in Firebase somewhere.
MaxthonSnap20190926105847

@duncancarroll
Copy link

@searchy2 Good find. A 1MB limit pretty much excludes full-resolution PNGs as many phones are 1024px wide, and a 1024x1024 PNG is nearly 2MB coming out of Photoshop.

@ciarand It would be awesome if this could be documented. If nothing else, a null check on the InputStream would be a good patch, as Ray indicated it may be affecting Play Store rankings.

@ksc91u
Copy link

ksc91u commented Oct 7, 2019

same issue here, even if image size < 1MB (around 180k)

@cabanel
Copy link

cabanel commented Oct 7, 2019

stesso problema qui, anche se la dimensione dell'immagine <1 MB (circa 180 k)

@rajiac2607
Copy link

I am also facing this,and the session in background is crashing

@gofur
Copy link

gofur commented Oct 17, 2019

any update for this issue?

i have same problem

java.lang.NullPointerException: at com.android.okhttp.okio.Buffer.write (Buffer.java:1182) at com.android.okhttp.okio.Buffer.read (Buffer.java:1221) at com.android.okhttp.okio.RealBufferedSource.read (RealBufferedSource.java:65) at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.read (Http1xStream.java:602) at com.android.okhttp.internal.Util.skipAll (Util.java:172) at com.android.okhttp.internal.Util.discard (Util.java:154) at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.close (Http1xStream.java:619) at com.android.okhttp.okio.RealBufferedSource.close (RealBufferedSource.java:421) at com.android.okhttp.okio.RealBufferedSource$1.close (RealBufferedSource.java:409) at com.google.android.gms.internal.firebase_messaging.zzk.zza at com.google.firebase.messaging.zzj.close at com.google.firebase.messaging.zzd.zza at com.google.firebase.messaging.FirebaseMessagingService.zzc at com.google.firebase.messaging.zze.run 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:764)

@duncancarroll
Copy link

@ashwinraghav @ciarand Any update on a fix for this? It's our #1 crash even after reducing image sizes to 512x512 JPGs (~20kb). Thanks!

@AlexeyGorovoy
Copy link

Comments seem to contradict one another about image sizes, for some, it fixes the issue, for others it doesn't.

I'll add my two cents here - for me the issue is massive in Crashlytics but isn't reproducible on my device. I even tried to deliberately crash it by trying to show 3mb image (notification just shows without an image) and by linking to a server that is programmed to return an image after 10 seconds, to hit the 5-sec timeout by Firebase (same as before, the notification shown without an image).

May it be that the issue isn't in the SDK, but rather in the Play Services installed on the device?

@MayuriKhinvasara
Copy link

MayuriKhinvasara commented Nov 18, 2019

We are getting similar hundreds of crashes, when sending image notifications through firebase console. Unable to reproduce locally, but 100+ crashes on crashlytics

@emywilk
Copy link

emywilk commented Nov 23, 2019

Several months later there's no fix. Can we at least get some feedback?

@Wallethub
Copy link

We have been getting it too and reported under #1006. Even after changing the images to be 512x256 the issue still comes. The images are around ~12kb, one being at 8kb. I don't think reducing image sizes helps at all.

@aguatno
Copy link

aguatno commented Dec 3, 2019

Hi All, our engineering team continues to investigate the issue internally using this bug#141328496. I'll let you know as soon as I have more information.

@aguatno aguatno added the type: bug Something isn't working label Dec 3, 2019
@aguatno
Copy link

aguatno commented Dec 10, 2019

The issue has been identified and fixed internally. Currently waiting when would be the external release date.

@aguatno
Copy link

aguatno commented Dec 12, 2019

Hi All, we released a new version of our Cloud Messaging SDK, see release notes. Please try update to latest 20.1.0 to see whether there is still such issue?

@aguatno aguatno removed the type: bug Something isn't working label Dec 12, 2019
@longyuan5
Copy link

longyuan5 commented Dec 13, 2019

Hi All, we released a new version of our Cloud Messaging SDK, see release notes. Please try update to latest 20.1.0 to see whether there is still such issue?

Crashlytics will still report NPE, which accounts for about 1% of the total。
implementation 'com.google.firebase:firebase-messaging:20.1.0'

@aguatno
Copy link

aguatno commented Dec 19, 2019

hi @longyuan5 could you confirm if the issue persists?

@duncancarroll
Copy link

I can confirm it is resolved in 20.1.0. Thanks team!

@aguatno
Copy link

aguatno commented Dec 19, 2019

Thanks. Closing this issue for now.

In case you guys still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@aguatno aguatno closed this as completed Dec 19, 2019
@firebase firebase locked and limited conversation to collaborators Jan 19, 2020
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