element-web icon indicating copy to clipboard operation
element-web copied to clipboard

Input new message is sometimes very slow (blocking for some seconds)

Open HerrBlauwasser opened this issue 2 years ago • 2 comments

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.

element-input-slow

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

HerrBlauwasser avatar Mar 31 '22 07:03 HerrBlauwasser

Can also reproduce in firefox, when multiple tabs are open. Can't provide any logs because my firefox crashes when saving them.

Konradrundfunk avatar Mar 31 '22 07:03 Konradrundfunk

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.

turt2live avatar Apr 01 '22 15:04 turt2live

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.

clarkf avatar Jan 07 '23 23:01 clarkf

I can confirm. This happens only in rooms which are encrypted, especially rooms with many users.

HerrBlauwasser avatar Jan 07 '23 23:01 HerrBlauwasser