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)"

Open
#9,039 1 comment 0 reactions 0 assignees View on GitHub
matrix-sdk
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.