element-hq / element-hq/element-android
[SDK] Realm instance not closing promptly during logout – "Waiting 10ms for all Realm instance to be closed (1 - 0)"
- Dominant language
- Kotlin
- Stars
- 3.7k
- Forks
- 917
- PR merge metrics
- No merged PRs in 30d
Description
### Description
During the logout process, the app logs repeated messages like:
`Waiting 10ms for all Realm instance to be closed (1 - 0)`
This suggests that a Realm instance remains open longer than expected, delaying the cleanup process.
I'm using this to logout
`session.signOutService().signOut(true)`
Please clarify what causes this delay and suggest best practices for ensuring Realm instance is closed promptly.
Logs
```
Cleanup: cancel pending works...
Cleanup: stop session...
Kill sync...
Update state from Running(afterPause=false) to org.matrix.android.sdk.api.session.sync.SyncState$Killing@6ed5318
SignOut: send request...
Cancelled
...Continue
Sync killed
Update state from org.matrix.android.sdk.api.session.sync.SyncState$Killing@6ed5318 to org.matrix.android.sdk.api.session.sync.SyncState$Killed@88d87d7
Storage of accounts to config file is skipped.
SignOut: cleanup session...
Cleanup: Realm instance (3 - 1)
Cleanup: release session...
Cleanup: delete session params...
Cleanup: clear session data...
Cleanup: clear crypto data...
Cleanup: clear the database keys
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
Cleanup: Waiting 10ms for all Realm instance to be closed (1 - 0)
....
....
....
Cleanup: clear file system
```
Contributor guide
Assessment
This issue has not been assessed yet.