conversejs / converse.js

Web-based XMPP/Jabber chat client written in JavaScript
http://conversejs.org
Mozilla Public License 2.0
3.09k stars 774 forks source link

Improvements to use large rosters #2221

Open abevieiramota opened 4 years ago

abevieiramota commented 4 years ago

I'm evaluating conversejs as a chat tool to a scenario where some users can have 200~1000 contacts in their roster. I've already seen in the docs the section Performance issues with large rosters and doing some tests with that scenario I had performance issues.

I cannot turn show_only_online_users true, because the users should be able to send message to offline users. I expect that, for example, a user with 1000 contacts will send messages to just ~20 contacts in a session, but they should be able to see all of the contacts.

So I started studying the code (and javascript) and I'm trying to figure out ways to customize it in order to improve its performance for large rosters.

Here are my current ideas to improve performance:

Beside the perfomance issues, I experienced some usability issues with the contacts sorted by nickname - some users asked for a contact lists sorted like Whatsapp/Telegram. So I tried to make the contacts sorted by the last message exchanged in its chatbox. In a first attempt I simple changed the comparator of RosterContacts, and I triggered a rosterContactsFetched when a message was sent or received. It worked, but I didn't know the side effects, and with large rosters it turned quite slow. I'm currently searching ways to just move a contact to the top of the contact lists, whenever a message is sent to them or send by them.

--- Want to back this issue? **[Post a bounty on it!](https://app.bountysource.com/issues/92794899-improvements-to-use-large-rosters?utm_campaign=plugin&utm_content=tracker%2F194169&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://app.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F194169&utm_medium=issues&utm_source=github).
jcbrand commented 4 years ago

Chats aren't loaded on demand because then you won't get notifications if you're mentioned in them.

Better support for web push and push notifications could help to fix that, but that's how it is currently.

I'm currently also looking at ways to better decouple the view layer from the logic/state layer, so that we can delay rendering the view layer to the last moment.

I've written down some thoughts here: https://github.com/conversejs/converse.js/wiki/Decouple-Skeletor-Views-from-Models

Concerning the roster itself, we're currently in the process of rewriting Backbone/Skeletor Views into LitElement custom elements. The roster views should also be rewritten to make use of components. This might very well speed things up, or in the least provide some opportunity to think about performance improvements that can be made.

That said, I'm personally not going to work on rewriting the roster view code any time soon (probably not this year). If someone else is keen to try, I'll be happy to provide directions and review.