-
Notifications
You must be signed in to change notification settings - Fork 4k
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_database]: When listening to '.info/connected' and display turns off, the connection state value flaps between true and false #13409
Comments
Hi @justChris , thanks for submitting this report. I am able to reproduce this issue. We will investigate further and provide feedback. Thanks! |
I forgot to mention, that when the display turns back on, the In my opinion, the expected behavior would be:
|
Hi @justChris , I’ve tested this issue with the latest version of firebase_database but wasn’t able to reproduce it. Could you update to the latest version and give it another try? |
@SelaseKay here you said you could reproduce the issue. Did you then update the package which fixed the issue? |
Correct. I could reproduce this issue initially on an older version. Updating the packages seems to resolve the issue on my end. |
@SelaseKay I have tested it and the flapping as well as the wrong eventual connection state is gone. Now the listener does not fire at all when the display turns off. Also the Database entry does not get removed immediately when display turns off. It seems iOS does not immediately cut the connection anymore when display turns off. I have the feeling it works more like android does now. I still have to test how it is behaving now when display turns off and then the internet connection is lost on the device. I assume the database entry gets removed like expected, but I have to check how the local listener behaves. I will give feedback. |
Is there an existing issue for this?
Which plugins are affected?
Database
Which platforms are affected?
iOS
Description
When listening to '.info/connected' and display turns off while the app is still in foreground, the connection state value flaps between true and false and is eventually true even though the client has disconnected from the server.
I know the client has disconnected because I'm creating a database entry at the first startup of the app and registering an onDisconnect() callback, which removes this entry from the database when the app disconnects.
So when I turn off the display, the database entry gets removed but the value of the local listener is eventually true.
This way I cannot reliably handle the connection state. Is that a bug? Do you have any suggestions to deal with this behavior?
Reproducing the issue
Just use the sample from https://firebase.google.com/docs/firestore/solutions/presence
Firebase Core version
3.5.0
Flutter Version
3.24.3
Relevant Log Output
Log output from debugLogs from above code sample:
$ flutter doctor -v
Flutter dependencies
Expand
Flutter dependencies
snippetAdditional context and comments
No response
The text was updated successfully, but these errors were encountered: