-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Olm is prone to race conditions across multiple tabs #2325
Comments
I think this is important. |
I've been doing some thinking about this. Implementing race-free concurrency between tabs via localstorage is hard, because Chrome (at least) just doesn't provide any promises in this area. We have no idea how long it takes a write in one process to be reflected in another, which makes any read-modify-write process inherently racy. Some options might be:
I guess we want to use IndexedDB with fallback to Localstorage. |
This causes corrupted olm sessions, so really does need to be p1 |
The situation is even worse with electron, which totally ignores updates which happen in another process: see electron/electron#2493. I have no idea how to fix this, currently. |
I can definitely reproduce this. Opening riot in two tabs (and sending messages from them) can break communication with peers in both directions. |
The secret third option is to bully people into only using one tab (but I don't like this). I like the idea of using IndexedDB; falling back to localstorage sounds like it will still have all the same problems when we do fall back - could we consider just not supporting firefox incognito until we have the bandwidth to carve out a reliable localstorage fallback option? |
The electron app is now single-instance, so this should mitigate this on electron. |
This will also be a problem for syncing device lists. |
Conclusion for Firefox private tabs is to fall back to in-memory storage for the crypto store rather than trying to keep the localstorage-backed session store as a fallback. The one downside of this is that e2e data won't be persisted if you hit refresh. |
Actually thinking about this more, the failure mode on upgrading would be terrible since you'd hit the update button in the new version bar and it would throw away all your e2e data. I've made it fall back to localstorage. |
This should be fixed now all the various parts have been migrated to indexeddb! |
If you have multiple tabs open for the same account, they will fight over the localstorage and corrupt each other.
Simple example: Two tabs run the "generate ephemeral keys" timer at the same time. They generate different keys, but only one set is successfully persisted in the Olm account. I suspect this has been happening to trilobite17, who likes to have multiple tabs open.
Another example:
The text was updated successfully, but these errors were encountered: