cinnyapp / cinny

Yet another matrix client
https://cinny.in
GNU Affero General Public License v3.0
1.95k stars 250 forks source link

Bug: Cinny loads 1,837 twemoji on startup #88

Closed BBaoVanC closed 2 years ago

BBaoVanC commented 3 years ago

Describe the bug

When Cinny is signed in, it loads 1,837 twemoji on startup, which uses a lot of bandwidth, and causes my browser to lag.

To Reproduce

Steps to reproduce the behavior:

  1. Open Network tab in developer console, and search "twemoji"
  2. Sign into Cinny (or be already signed in)
  3. See a lot of requests

Expected behavior

The twemoji should be loaded when they're sent/received in chat (and/or cached), not all at once on startup.

Screenshots

1,837 requests to twemoji.maxcdn.com, totalling 2.45 MB (1.40 MB compressed)

Desktop (please complete the following information):

hifi commented 3 years ago

Additionally all of these need to be locally available from the built bundle and not loaded from an external website. Same for fonts.

kfiven commented 3 years ago

These are only loaded from cdn during first sign in, rest of the time we load them from cache.

And I don't think making them locally available will change anything because then we'll have to load them like we load icons now.

What needs to be done is delay the loading so that it doesn't hang loading screen.

kfiven commented 3 years ago

or load them when people open emojiboard.

hifi commented 3 years ago

There are tons of reasons not to use a CDN. First and foremost it makes Cinny depend on a random CDN to even function properly, then packaging Cinny (in any shape or form) is impossible as it will require resources that are not part of the build (think mobile and desktop). It also makes Cinny unsuitable to use in internal communication without internet access however unlikely that scenario is. It also makes self hosting Cinny not really a thing as it's not fully contained anyway.

Loading thousands of emojis to memory even when you only see something like sub-100 at most per day is wasted resources where Cinny certainly seems to aim at being lightweight. It definitely should lazy load them on demand and then let the browser cache do its magic in the future making lazy loading practically instant.

It's fine at this point in time to use a CDN as a first step but it needs to be replaced in the long run.

vinceTheProgrammer commented 3 years ago

or load them when people open emojiboard.

I don't know anything about web requests, CDNs, or twemoji, but if that would just make it lag when you open the emojiboard instead of on first sign in, then I'm definitely against it. I would much rather it load on startup so that my flow isn't interrupted mid session when I open the emojiboard.

If you're talking lazy loading tho, I think that could work.

N-R-K commented 2 years ago

I would suggest not lazy loading everything. Since there's a handful of emojies which are often used, pack them into a "frequently used" group and pre-load these. The rest can be lazily loaded.