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

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

Open
HerrBlauwasser opened this issue Mar 31, 2022 · 4 comments
Open
Labels
A-Composer A-E2EE A-Performance good first issue Good for newcomers Hacktoberfest Issues which are suitable for Hacktoberfest PRs: https://hacktoberfest.digitalocean.com/ Help Wanted Extra attention is needed O-Occasional Affects or can be seen by some users regularly or most users rarely S-Major Severely degrades major functionality or product features, with no satisfactory workaround T-Defect

Comments

@HerrBlauwasser
Copy link

HerrBlauwasser commented Mar 31, 2022

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

@Konradrundfunk
Copy link

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

@germain-gg germain-gg added A-Performance S-Major Severely degrades major functionality or product features, with no satisfactory workaround A-E2EE O-Occasional Affects or can be seen by some users regularly or most users rarely labels Mar 31, 2022
@turt2live turt2live added the good first issue Good for newcomers label Apr 1, 2022
@turt2live
Copy link
Member

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.

@kittykat kittykat added the Help Wanted Extra attention is needed label May 4, 2022
@clarkf
Copy link

clarkf commented Jan 7, 2023

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.

@HerrBlauwasser
Copy link
Author

HerrBlauwasser commented Jan 7, 2023

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

clarkf added a commit to clarkf/matrix-js-sdk that referenced this issue Jan 8, 2023
Currently, calling `Client#prepareToEncrypt` in a megolm room has the potential
to block for multiple seconds while it crunches numbers.

Sleeping for 0 seconds (approximating `setImmediate`) allows the engine to
process other events, updates, or re-renders in between checks.

See
- element-hq/element-web#21612
- element-hq/element-web#11836

Signed-off-by: Clark Fischer <clark.fischer@gmail.com>
clarkf added a commit to clarkf/matrix-js-sdk that referenced this issue Jan 16, 2023
Currently, calling `Client#prepareToEncrypt` in a megolm room has the potential
to block for multiple seconds while it crunches numbers.

Sleeping for 0 seconds (approximating `setImmediate`) allows the engine to
process other events, updates, or re-renders in between checks.

See
- element-hq/element-web#21612
- element-hq/element-web#11836

Signed-off-by: Clark Fischer <clark.fischer@gmail.com>
@Johennes Johennes added the Hacktoberfest Issues which are suitable for Hacktoberfest PRs: https://hacktoberfest.digitalocean.com/ label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Composer A-E2EE A-Performance good first issue Good for newcomers Hacktoberfest Issues which are suitable for Hacktoberfest PRs: https://hacktoberfest.digitalocean.com/ Help Wanted Extra attention is needed O-Occasional Affects or can be seen by some users regularly or most users rarely S-Major Severely degrades major functionality or product features, with no satisfactory workaround T-Defect
Projects
None yet
Development

No branches or pull requests

8 participants