status-im / status-mobile

a free (libre) open source, mobile OS for Ethereum
https://status.app
Mozilla Public License 2.0
3.91k stars 984 forks source link

Spectated communities are never closed #20594

Open ilmotta opened 4 months ago

ilmotta commented 4 months ago

Problem

When a user opens a community but never joins it, the community stays in the spectated state and accessible in the Opened tab in the home screen, forever, even after logout. Each spectated community will eat considerable resources, much like a community the user has joined. This is a form of resource leak.

The main performance cost here for the mobile app comes from the overhead of keeping the state in sync as signals arrive for a community (esp. a large one), given that we globally process signals independently of the current screen the user is at.

Original discussion in https://github.com/status-im/status-mobile/pull/20508#issuecomment-2188587426.

Implementation

Based on a private discussion with @cammellos:

  1. Spectated communities would be sort of garbage collected every X time (like once every 7 days if the user hasn't interacted with the spectated community).
  2. Limit the insertion of new spectated communities to a max number of 5-10, or any small(ish) number and in a FIFO fashion.

This automatic approach should be preferred because it could be confusing to users to leave/close/unspectate communities manually. Additionally, it wouldn't be obvious to users why manually closing spectated communities is necessary.

Scope

Although the problem exists in theory, it shouldn't affect users at the moment because creating communities is disabled on status-desktop and creation is also not available on mobile, therefore we should postpone work on this issue.

ilmotta commented 4 weeks ago

I checked the Desktop app and it does something different. It actually allows the user to close a spectated community by right clicking and choosing the option "Close Community". The endpoint called is wakuext_leaveCommunity.

We should do the same and not go for the more complicated garbage collection approach mentioned in the issue description. Ideally, this issue should be solved alongside https://github.com/status-im/status-mobile/issues/20762, otherwise the user will have to frequently close spectated communities because we incorrectly spectate them automatically whenever Discover Communities is opened.

In the desktop app, the user doesn't see any confirmation pop-up when leaving a spectated community. We can add an option to the community drawer saying "Close Community" when long pressing on a spectated community.

To anyone working on this issue, please confirm with designers this is the expected behavior before proceeding with implementation.