firebase-unity-sdk icon indicating copy to clipboard operation
firebase-unity-sdk copied to clipboard

Auth and DB Task Cancellation

Open jmarisalandanan opened this issue 5 years ago • 5 comments

Please fill in the following fields:

Unity editor version: Firebase Unity SDK version: 2018.3 Firebase plugins in use (Auth, Database, etc.): Auth, Database Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac Platform you are targeting (iOS, Android, and/or desktop): Android

Just a question, is there any known way/example on cancelling auth and DB tasks? I want to do something like a timeout and cancel started tasks in case of poor/no network. Additionally I need to cancel tasks if user leaves the screen while auth and DB tasks are not finished.

jmarisalandanan avatar Jul 08 '19 09:07 jmarisalandanan

Unfortunately, currently there is no way to cancel the tasks from Auth and Database. The best you could do now is handle it in the task completion, undoing whatever action is needed if you want to.

a-maurice avatar Jul 09 '19 00:07 a-maurice

Thanks for the answer! That could work, how ever in the case of Timeout because of poor/no network task wouldn't get completed right? Any ideas on how to handle this properly? I'm currently thinking of possible workarounds for this, just asking in case you have any insights on how to approach this matter.

jmarisalandanan avatar Jul 12 '19 08:07 jmarisalandanan

@jmarisalandanan AFAIK, Database on Android would attempt to reconnect back to the server in poor/no network condition. And it will fail the Task if it retried too many times. I think Auth should have similar mechanics.

There is no proper way to actually implement timeout and cancel operation from C# level. Even you throw away the Task you got, in Android SDK level, it will still attempt to send the request until it gave up.

Shawn

chkuang-g avatar Jul 27 '19 05:07 chkuang-g

hehe this was exactly was I was looking for, it's a shame it's not possible. pistoleta.

pistoleta avatar Mar 11 '20 09:03 pistoleta

Will we have the ability to cancel the task? or set a shorter timeout?

I know I can check if Application has connectivity before calling the Firebase functions. On mobile losing connection is quite common in spotty areas. Currently in my editor, the firebase cloud function call is taking 2min 30sec to time out. It's way too long for players to wait. I could time out the UI, force player to go back 1 screen and let the task run in the background. But if player trigger the call again before the timeout, it would eventually crash Unity. :-(

kimcatsq avatar Jul 01 '20 16:07 kimcatsq