matrix-org / matrix-ios-sdk

The Matrix SDK for iOS
Apache License 2.0
451 stars 211 forks source link

Invalidate crypto store cache when entering foreground #1854

Closed BillCarsonFr closed 4 months ago

BillCarsonFr commented 4 months ago

Pull Request Checklist

depends on https://github.com/matrix-org/matrix-rust-sdk/pull/3462

Partial fix for the NSE process causing olm session wedging. See element-x related issue https://github.com/matrix-org/matrix-rust-sdk/issues/3110.

The crypto store is keeping a cache of olm sessions for a given device. When using multiprocess this cache will get outdated and causing session wedging. If the main app is inactive and the NSE do process a sync new olm sessions might be created (or mutated, like when replying to a key request). If the main process is then resumed it will use it's outdated cache instead of reloading from store.

The improvement here is that we will invalidate the cache when the main app enters foreground to limit the possible occurences of outdated caches.