1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[android] Firebase Cloud MessagingでNullPointerExceptionする

Last updated at Posted at 2019-09-17

起きたこと

Firebase Cloud Messagingを使ってandroidの端末にpush通知を送付したところ、3〜5%程度の割合でクラッシュが発生。

stacktrace

こんな感じのstacktraceが吐かれていた

Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'int com.android.okhttp.okio.Segment.limit' on a null object reference
       at com.android.okhttp.okio.Buffer.write + 1182(Buffer.java:1182)
       at com.android.okhttp.okio.Buffer.read + 1221(Buffer.java:1221)
       at com.android.okhttp.okio.RealBufferedSource.read + 55(RealBufferedSource.java:55)
       at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.read + 393(Http1xStream.java:393)
       at com.android.okhttp.internal.Util.skipAll + 159(Util.java:159)
       at com.android.okhttp.internal.Util.discard + 141(Util.java:141)
       at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.close + 410(Http1xStream.java:410)
       at com.android.okhttp.okio.RealBufferedSource.close + 396(RealBufferedSource.java:396)
       at com.android.okhttp.okio.RealBufferedSource$1.close + 384(RealBufferedSource.java:384)
       at com.google.android.gms.internal.firebase_messaging.zzk.zza + 4(com.google.firebase:firebase-messaging@@19.0.1:4)
       at com.google.firebase.messaging.zzi.close + 37(com.google.firebase:firebase-messaging@@19.0.1:37)
       at com.google.firebase.messaging.zzb.zza + 51(com.google.firebase:firebase-messaging@@19.0.1:51)
       at com.google.firebase.messaging.FirebaseMessagingService.zzc + 59(com.google.firebase:firebase-messaging@@19.0.1:59)
       at com.google.firebase.messaging.zzg.run + 2(com.google.firebase:firebase-messaging@@19.0.1:2)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
       at com.google.android.gms.common.util.concurrent.zza.run + 6(:6)
       at java.lang.Thread.run + 764(Thread.java:764)

ここではfirebase-messagingは19.0.1を使っているが、最新の20.0.0でも発生する。

原因

調べたところ、大きい画像を添付しているとクラッシュするらしい。
閾値は不明だが、300KBぐらいの画像だとクラッシュしていて、50KB程度だと大丈夫な感触。

参考

現在本家のFirebase-SDKにissueが上がっており対応中の様子

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?