element-hq / element-web

A glossy Matrix collaboration client for the web.
https://element.io
GNU Affero General Public License v3.0
11.21k stars 2k forks source link

Element-R: lock out multiple tabs to avoid races #25157

Closed richvdh closed 1 year ago

richvdh commented 1 year ago

Using the Rust crypto SDK from two tabs at once will cause data corruption, due to the fact that the rust-sdk caches information in memory.

Examples of the sorts of problems that could arise:

richvdh commented 1 year ago

A (somewhat hacky) option might be to lock out multiple tabs, by sending messages over a BroadcastChannel

richvdh commented 1 year ago

for now at least, we will lock out one of the tabs.

Element Call have done something like this and we may be able to benefit from their implementation

richvdh commented 1 year ago

I could probably do with some design input on this. Currently I have thrown together a page that looks like this:

image

nadonomy commented 1 year ago

@richvdh can we add some kind of interaction to choose which tab to use Element in? For example, WhatsApp web has this:

Screenshot 2023-08-17 at 17 02 54

Separately, can we use Element UI components? Or does this page need to be some kind of barebones HTML/styling?

If the latter, I'll whip something together copying the mobile install guide.

richvdh commented 1 year ago

the answer is (I think) "yes" to both, though we're deliberately trying to keep this feature lightweight as it's meant to be a quick alternative to "proper" multitab support.

I might need help from someone like @germain-gg in using UI components in EW properly, but it's just react components like the rest of EW so should be fine.

richvdh commented 1 year ago

@nadonomy I made a loading screen that looks like this:

image

Flightkick commented 1 year ago

@richvdh Thanks, this is awesome! Had my config drop twice this week because I accidentally opened element in another tab. Quite frustrating to re-auth and verify again. Lovely QOL feature!

richvdh commented 1 year ago
  1. There's no need to be sarcastic. We know this is frustrating, but we didn't do it just to annoy people. The description at the top of the issue explains the reasons it is necessary.
  2. This shouldn't cause you to have to re-auth. Please open a new issue describing your symptoms more clearly.
Flightkick commented 1 year ago

@richvdh sorry for not replying earlier, I just noticed your response. My enthusiasm was genuine, although I can understand how it may have come across as sarcasm.

I added my frustration for context. I can't quite remember how I landed here at the time, but the concurrent access of browser storage may have had something to do with it. The exact details are vague to me at this point.

Anyhow, upon looking for a solution I stumbled upon this feature you made very recently and I was pleased to discover that opening another tab will soon be handled more gracefully. Sharing the frustration was meant to let you know that this solves a PITA for me, hence the compliment on the QOL feature.

nukeop commented 1 year ago

This sucks: not only do I open multiple tabs so that I don't have to switch between different contexts manually, this triggers even if it's open in a single tab, and I have to reload Element to fix it, with all the usual punishments for reloading. Please revert this.

richvdh commented 1 year ago

I'm afraid we can't revert this, as it is currently required to support use of the new cryptography library, which is central to our strategy for making encryption more reliable.

We will track restoring multi-tab support at https://github.com/vector-im/element-web/issues/26231.