element-web
element-web copied to clipboard
Input new message is sometimes very slow (blocking for some seconds)
Steps to reproduce
Type a new message.
Outcome
What did you expect?
The message appears immediately while typing.
What happened instead?
The page blocks and the message appears seconds after typing.
The keydown event handler ist blocking for several seconds, caused by getDevicesInRoom(). Please find attached a screenshot of the performance inspector.
Operating system
Linux
Browser information
Version 99.0.4844.74 (Official Build) (64-bit)
URL for webapp
No response
Application version
Element Version: 1.10.7 Olm Version: 3.2.8
Homeserver
Synapse 1.55.0
Will you send logs?
No
Can also reproduce in firefox, when multiple tabs are open. Can't provide any logs because my firefox crashes when saving them.
I've flagged this as a good first issue, though adventurers should note that it's more on the challenging side. Visit #element-dev:matrix.org on Matrix for support in working on this issue.
I believe I've tracked this down to the following lines:
https://github.com/matrix-org/matrix-react-sdk/blob/ff34fc71d9e135320e1fe84f1713265a3bf38093/src/components/views/rooms/SendMessageComposer.tsx#L254-L257
(That's the default
case of an onKeyDown
handler for the primary chat input, however, it is throttled).
My understanding after poking through the code is that this issue should occur only in megolm environments, i.e. encrypted group chats. Is that correct?
The profiling above indicates that Crypto#checkDeviceTrust
is where time's being spent. I'd guess this is most noticeable in large groups, or groups with many subscribed devices.
I can confirm. This happens only in rooms which are encrypted, especially rooms with many users.