Skip to content
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

Create lazy in-memory room encryptors #1570

Merged
merged 2 commits into from
Sep 5, 2022
Merged

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Sep 5, 2022

The existing [MXCrypto getRoomEncryptor] method is used by a variety of codepaths, incl. re-sharing room keys etc. It returns a cached / in-memory value of MXMegolmEncryptor, but only if it was previously set to memory, typically by ensureEncryptionInRoom method (which performs a bunch of other actions). This method is typically called when a user starts typing in a given room.

When a user launches the app the roomEncryptors dictionary will be empty for all rooms, and encryptors will only be created if a user types a message in that room, or some message arrives to this device. It is not however created when the user receives a m.room_key_request for this room, and thus silently fails in re-sharing a given key, leaving the requester with UISIs.

To solve this, this PR ensures that getRoomEncryptor can instantiate an in-memory encryptor if it does not exist already, rather than waiting on ensureEncryptionInRoom to be called. That way we always return an encryptor when needed, and the client will respond to key requests even after fresh app start

@Anderas Anderas requested review from a team and pixlwave and removed request for a team September 5, 2022 08:33
@codecov-commenter
Copy link

Codecov Report

Merging #1570 (0ff11b5) into develop (f208215) will increase coverage by 0.02%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop    #1570      +/-   ##
===========================================
+ Coverage    12.46%   12.48%   +0.02%     
===========================================
  Files          521      521              
  Lines        85025    85051      +26     
  Branches     36203    36217      +14     
===========================================
+ Hits         10598    10622      +24     
- Misses       74041    74043       +2     
  Partials       386      386              
Impacted Files Coverage Δ
MatrixSDK/Crypto/MXCrypto.m 2.02% <0.00%> (-0.03%) ⬇️
MatrixSDKTests/MXHTTPAdditionalHeadersUnitTests.m 76.59% <0.00%> (-8.52%) ⬇️
MatrixSDK/Crypto/MXOlmDevice.m 24.26% <0.00%> (+2.04%) ⬆️
MatrixSDK/Utils/MXLRUCache.m 40.84% <0.00%> (+26.76%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@Anderas
Copy link
Contributor Author

Anderas commented Sep 5, 2022

Confirmed that failing integration tests pass locally

@Anderas Anderas merged commit 2b96b99 into develop Sep 5, 2022
@Anderas Anderas deleted the andy/lazy_encryptors branch September 5, 2022 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants