element-hq / element-desktop

A glossy Matrix collaboration client for desktop.
https://element.io
GNU Affero General Public License v3.0
1.16k stars 266 forks source link

Increased room loading times with link previews enabled (on desktop after v1.11.81) #1983

Open krassle opened 5 days ago

krassle commented 5 days ago

Steps to reproduce

  1. Open Element Desktop
  2. Switch to a room with inline URL previews enabled and lots of links inside (e.g. news-feeds)
  3. Observe loading times of up to 9-10 seconds
  4. Be stuck until avatars and link previews are fully loaded
  5. Also observe: timeline scrolling isn't smooth like before
  6. Issue appears on every room switch, not just the fist one

Additional info:

Issue first started with release 1.11.82 of Element Desktop (persists with .83/.84). Reverting back to 1.11.81 fixes the issue (loading times back to normal 1-2 seconds and smooth scrolling). Comparing 1.11.81...1.11.82 - not much changed there. Perhaps someone can spot the regression introduced...

Important: Element Web appears to be unaffected by this.

(Chrome DevTools) Performance - screenshot of room loading times

Bildschirmfoto_2024-11-08_16-05-01

(Chrome DevTools) Console logs - nothing really helpful

vector-1731079305676.log

Outcome

What did you expect?

Short loading times of max. 1-2 seconds(when switching rooms) and smooth scrolling

What happened instead?

Loading times increased by a factor of 5 after v1.11.81

Operating system

Debian Linux

Application version

Element version: 1.11.84

How did you install the app?

https://packages.element.io/debian

Homeserver

Synapse 1.118.0

Will you send logs?

Yes

t3chguy commented 5 days ago

Comparing 1.11.81...1.11.82 - not much changed there. Perhaps someone can spot the regression introduced...

The change would be in element-web or matrix-react-sdk

krassle commented 5 days ago

Forgot to attach the performance tab of the unaffected v1.11.81

(Chrome DevTools) Performance Recorder - v1.11.81

Bildschirmfoto_2024-11-08_18-38-57

t3chguy commented 5 days ago

Important: Element Web appears to be unaffected by this.

Element Desktop is just Element Web + Electron so that seems odd.

v1.11.82 switched the room header implementation and there are complaints of performance issues with that: https://github.com/element-hq/element-web/issues/28273

krassle commented 5 days ago

@t3chguy I have no idea why Element Web would behave differently than Element Desktop, but on my self-hosted Element Web instance the issue is not reproducible on any version between 1.11.81 and 1.11.84. So, it must be some minor code difference affecting only Desktop, as Electron was not updated to a new major version ...

t3chguy commented 5 days ago

So, it must be some minor code difference affecting only Desktop, as Electron was not updated to a new major version ...

There is no Desktop code for URL previews, its just the Element web embedded within Electron responsible for it

krassle commented 2 days ago

Important: Element Web appears to be unaffected by this.

Element Desktop is just Element Web + Electron so that seems odd.

v1.11.82 switched the room header implementation and there are complaints of performance issues with that: element-hq/element-web#28273

The issue you mentioned (about the new room headers) maybe not linked to this one after all, then:

  1. it is reported to affect rooms with many participants(e.g. Matrix-HQ), where this one is about rooms with only the RSS-Bot inside
  2. it emphasizes the high CPU usage and not the increased room loading times
  3. it appears to affect both Element Web & Element Desktop, where here clearly only Element Desktop is affected

But then URL previews may also have less or nothing to do with this problem... A recent unresolved issue(Media redirect target URL gets modified by Element Desktop #1924) leads me to suspect that recently introduced target URL rewriting may somehow negatively interfere with loading / fetching (or caching) of media-thumbnails in some reverse proxy or media content repository scenarios. The author also explicitly points out the different behavior between Element Web and Desktop in this regard.

Please let me know if I can perform any more debugging steps to help narrow it down. Thanks.