firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
820 stars 424 forks source link

[Bug] Firestore crash when using Android emulator #1065

Open Nyankoo opened 3 years ago

Nyankoo commented 3 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

E/AndroidRuntime( 5020): FATAL EXCEPTION: main
E/AndroidRuntime( 5020): Process: com.example.game, PID: 5020
E/AndroidRuntime( 5020): java.lang.Error: FATAL EXCEPTION [main]
E/AndroidRuntime( 5020): Unity version     : 2020.3.9f1
E/AndroidRuntime( 5020): Device model      : samsung SM-G955N
E/AndroidRuntime( 5020): Device fingerprint: samsung/SM-G955N/dream2lteks:5.1.1/NRD90M/500200305:user/release-keys
E/AndroidRuntime( 5020): Build Type        : Release
E/AndroidRuntime( 5020): Scripting Backend : IL2CPP
E/AndroidRuntime( 5020): ABI               : armeabi-v7a
E/AndroidRuntime( 5020): Strip Engine Code : true

E/AndroidRuntime( 5020): Caused by: java.lang.RuntimeException: Internal error in Cloud Firestore (22.1.2).

E/AndroidRuntime( 5020):    at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:534)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(AsyncQueue.java)
E/AndroidRuntime( 5020):    at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime( 5020):    at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 5020):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 5020):    at android.app.ActivityThread.main(ActivityThread.java:5307)
E/AndroidRuntime( 5020):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 5020):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 5020):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
E/AndroidRuntime( 5020):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
E/AndroidRuntime( 5020): Caused by: java.lang.IllegalArgumentException: Timestamp seconds out of range: 6967862201976803777
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.util.Preconditions.checkArgument(Preconditions.java:117)
E/AndroidRuntime( 5020):    at com.google.firebase.Timestamp.validateRange(Timestamp.java:159)
E/AndroidRuntime( 5020):    at com.google.firebase.Timestamp.<init>(Timestamp.java:63)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.RemoteSerializer.decodeTimestamp(RemoteSerializer.java:110)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.RemoteSerializer.decodeVersion(RemoteSerializer.java:121)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.RemoteSerializer.decodeWatchChange(RemoteSerializer.java:873)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:106)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:38)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onNext$1(AbstractStream.java:119)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver$$Lambda$2.run(AbstractStream.java)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onNext(AbstractStream.java:110)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.remote.FirestoreChannel$1.onMessage(FirestoreChannel.java:125)
E/AndroidRuntime( 5020):    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:658)
E/AndroidRuntime( 5020):    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:643)
E/AndroidRuntime( 5020):    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
E/AndroidRuntime( 5020):    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
E/AndroidRuntime( 5020):    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
E/AndroidRuntime( 5020):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime( 5020):    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
E/AndroidRuntime( 5020):    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
E/AndroidRuntime( 5020):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime( 5020):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime( 5020):    at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:229)
E/AndroidRuntime( 5020):    at java.lang.Thread.run(Thread.java:818)
W/ActivityManager( 1779):   Force finishing activity 1 com.example.game/com.google.firebase.MessagingUnityPlayerActivity

Steps to reproduce:

Relevant Code:

paulinon commented 3 years ago

Hi @Nyankoo,

In order to identify what's causing this behavior, could you share a minimal, reproducible example of your project along with the steps you've taken before facing this issue?

schmidt-sebastian commented 3 years ago

Furthermore, are you able to share debug logs if this is reproducible? You can change the log level with this API: https://firebase.google.com/docs/reference/unity/namespace/firebase#namespace_firebase_1ae165d1d7bc3d85e1c0463a2a1d9ced9a

If you change the log level to DEBUG then will be able to see the messages that the SDK receives from the backend.

Nyankoo commented 3 years ago

@schmidt-sebastian I'm still trying to recreate this in a minimal repro, but in the meantime, you can find the complete logcat with DEBUG enabled here.

62001_logcat.txt

schmidt-sebastian commented 3 years ago

Unfortunately, Firestore only logs its network traffic when the log level is explicitly set to debug. Even if you cannot create a minimal repro, a debug log that shows the network traffic would help tremendously.

Nyankoo commented 3 years ago

@schmidt-sebastian The log level is set to debug in the above logcat file (with FirebaseApp.LogLevel = LogLevel.Debug)

schmidt-sebastian commented 3 years ago

The log level for Firestore is independent from FirebaseApp. You should see some log messages that show the communication from the WatchStream and the WriteStream.

Nyankoo commented 3 years ago

@schmidt-sebastian Any guides or pointers how to correctly set this up so I can provide a useful logcat?

var-const commented 3 years ago

You can use

FirebaseFirestore.LogLevel = LogLevel.Debug;
Nyankoo commented 3 years ago

@var-const Thank you!

@schmidt-sebastian Please find the logcat with WatchStream and WriteStream below. 62001_logcat.txt

schmidt-sebastian commented 3 years ago

@Nyankoo This is very helpful and exactly what I need. Thank you.

schmidt-sebastian commented 3 years ago

@Nyankoo Are you talking to our production backend or to the Emulator?

Nyankoo commented 3 years ago

@schmidt-sebastian What exactly do you mean?

schmidt-sebastian commented 3 years ago

Are you using "useEmulator()" in your app and talking to "localhost" instead of "firestore.googleapis.com"?

Nyankoo commented 3 years ago

@schmidt-sebastian I'm not using any special emulator-related methods.

Nyankoo commented 3 years ago

We also just had the same crash report through Crashlytics on a Reno Ace with Android 5.1.1, but we can't confirm if this is actually an emulator or real device on the user's end.

Nyankoo commented 3 years ago

@schmidt-sebastian Any progress with this issue?

schmidt-sebastian commented 2 years ago

We believe this is invalid data coming from the backend. We have a bug to track this - b/191139962. There are no updates yet.

potatoyz commented 7 months ago

Hello, has this bug been fixed? We also encountered this problem.

11-14 01:35:05.441 E/AndroidRuntime( 2969): FATAL EXCEPTION: main
11-14 01:35:05.441 E/AndroidRuntime( 2969): Process: , PID: 2969
11-14 01:35:05.441 E/AndroidRuntime( 2969): java.lang.Error: FATAL EXCEPTION [main]
11-14 01:35:05.441 E/AndroidRuntime( 2969): Unity version     : 2020.3.48f1c1
11-14 01:35:05.441 E/AndroidRuntime( 2969): Device model      : Xiaomi MI 5s
11-14 01:35:05.441 E/AndroidRuntime( 2969): Device fingerprint: OnePlus/OnePlus2/OnePlus2:6.0.1/MMB29M/1447841200:user/release-keys
11-14 01:35:05.441 E/AndroidRuntime( 2969): Build Type        : Release
11-14 01:35:05.441 E/AndroidRuntime( 2969): Scripting Backend : IL2CPP
11-14 01:35:05.441 E/AndroidRuntime( 2969): ABI               : x86
11-14 01:35:05.441 E/AndroidRuntime( 2969): Strip Engine Code : true
11-14 01:35:05.441 E/AndroidRuntime( 2969): 
11-14 01:35:05.441 E/AndroidRuntime( 2969): Caused by: java.lang.RuntimeException: Internal error in Cloud Firestore (24.9.1)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.util.AsyncQueue.p(AsyncQueue.java:5)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.util.h.run(lambda)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at android.os.Handler.handleCallback(Handler.java:739)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at android.os.Handler.dispatchMessage(Handler.java:95)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at android.os.Looper.loop(Looper.java:148)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at android.app.ActivityThread.main(ActivityThread.java:5654)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at java.lang.reflect.Method.invoke(Native Method)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:672)
11-14 01:35:05.441 E/AndroidRuntime( 2969): Caused by: java.lang.IllegalArgumentException: Timestamp seconds out of range: 7301194837235273221
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.util.e0.a(Preconditions.java:1)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.Timestamp.validateRange(Timestamp.java:4)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.Timestamp.<init>(Timestamp.java:2)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.o0.w(RemoteSerializer.java:1)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.o0.y(RemoteSerializer.java:3)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.o0.A(RemoteSerializer.java:23)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.x0.y(WatchStream.java:2)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.x0.r(WatchStream.java:1)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.z$c.i(AbstractStream.java:6)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.z$c.j(AbstractStream.java)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.c.run(lambda)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.z$a.a(AbstractStream.java:3)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.z$c.d(AbstractStream.java:1)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.remote.j0$a.c(FirestoreChannel.java:1)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at g.a.s1.z$k.c(DelayedClientCall.java:2)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at g.a.s1.p$d$b.b(ClientCallImpl.java:4)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at g.a.s1.p$d$b.a(ClientCallImpl.java:3)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at g.a.s1.x.run(ContextRunnable.java:2)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at g.a.s1.d2.run(SerializingExecutor.java:3)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at com.google.firebase.firestore.util.AsyncQueue$c$b.run(AsyncQueue.java:3)
11-14 01:35:05.441 E/AndroidRuntime( 2969):     at java.lang.Thread.run(Thread.java:818)
11-14 01:35:05.442 W/ActivityManager(  729):   Force finishing activity com.unity3d.player.UnityPlayerActivity