fix: Megolm sessions become invalid after restarting client

This bug seems to be in the
sdk for 5 years already without
anyone noticing. The method
loadInboundGroupSession
seems to return the wrong
variable when loading the
session from the key. While
the outboundgroupsession
loading method relies on
an inbound group session, it
silently marks the outbound
group session as invalid on
every restart and creates a
new one. This means we never
reuse megolm sessions after
restarting the client.

Fixing this will probably reduce
the amount of megolm sessions
used in a conversation by a lot
which could improve the
performance and make the
key backup more reliable.
This commit is contained in:
Krille 2025-02-03 09:12:30 +01:00
parent 0874488110
commit 6cd40d3f91
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
1 changed files with 3 additions and 2 deletions

View File

@ -289,8 +289,7 @@ class KeyManager {
dbSess.sessionId != sessionId) { dbSess.sessionId != sessionId) {
return null; return null;
} }
roomInboundGroupSessions[sessionId] = dbSess; return roomInboundGroupSessions[sessionId] = dbSess;
return sess;
} }
Map<String, Map<String, bool>> _getDeviceKeyIdMap( Map<String, Map<String, bool>> _getDeviceKeyIdMap(
@ -348,6 +347,8 @@ class KeyManager {
sess.outboundGroupSession!.session_id(), sess.outboundGroupSession!.session_id(),
); );
if (inboundSess == null) { if (inboundSess == null) {
Logs().w('No inbound megolm session found for outbound session!');
assert(inboundSess != null);
wipe = true; wipe = true;
} }