element-hq / element-hq/element-web

Element should ignore events it cannot process (IoT)

Open
#22,662 7 comments 1 reaction 0 assignees View on GitHub
A-Performance A-Timeline O-Occasional S-Tolerable T-Enhancement
Dominant language
TypeScript
Stars
13.5k
Forks
2.8k
PR merge metrics
PR metrics pending

Description

### Discussed in https://github.com/vector-im/element-meta/discussions/487

Originally posted by **turt2live** February 18, 2017
[![bounty](https://api.bountysource.com/badge/issue?issue_id=42187230)](https://www.bountysource.com/issues/42187230-riot-should-ignore-events-it-cannot-process-iot)

### Description

TL;DR: I made something that sent 43,200 custom events and Riot doesn't like me anymore.

*Backstory*: I started work on [matrix-temperature-logger](https://github.com/turt2live/matrix-temperature-logger) - a project to record basic weather data to a Matrix room for processing by other parties. The project uses a custom event (`io.t2l.matrix.weather`) to send this data to the room. Riot apparently tries to cache these events, despite it not knowing how to handle them, leading to some pretty significant degradation of performance as time goes on.

The project currently sends 1 event per second, and after 12 hours of run time that's **~43,200** events that have ended up in the room. The new indexeddb improvements help a lot with processing the thousands of events, however it still seems to reduce performance whenever I enter that room.

Each time I click on that room, I expect to see the few state events and couple messages that Riot can show me, however the spinner goes wild (flashing in and out of view) while it tries to load the thousands of weather events. As it loads more and more, the spinner gets slower and slower (and the UI gets less and less responsive). At the time of writing this, it takes about 5 minutes for Riot to show me everything in the room (see screenshot).

**Note**: I fully recognize that 43,200 invisible events is ridiculous and may even be abusing the intended use case of Matrix. However, I feel as though Riot should intentionally drop these messages from it's cache and pretend they never happened so the room is still usable as a communication room (which is what I was going for - people chatting with weather data silently being transferred without the participants noticing, unless you're the bot handling it all).

When trying to investigate what was causing the spinner to slow down, I found that Riot was generating DOM elements for each event like so: `

  • ` - this is probably what caused the increasingly poor performance of the entire application (it also makes Chrome's dev tools very unhappy).

    ### Steps to reproduce

    - Have something that sends a plethora of custom events to a room
    - Let that something run wild to generate tens of thousands of events
    - Try and navigate to the room in Riot
    - Note how the spinner behaves and performance degrades increasingly until it finishes

    *I do have a test room with these events available. Feel free to ask me (`@travis:t2l.io`) for an invite if you're looking to avoid the hassle of generating thousands of events.*

    *Describe how what happens differs from what you expected.*
    I would have expected Riot to ignore the events that it can't handle, but it instead tried to create a timeline out of them.

    Log: not sent (can't).

    This is what the room looks like after it's done loading the tens of thousands of events:
    ![image](https://cloud.githubusercontent.com/assets/1190097/23097030/f50e181a-f5e6-11e6-9423-59df0463dcc2.png)

    Here's a snippet of the DOM inspector:
    ![image](https://cloud.githubusercontent.com/assets/1190097/23097034/0b6613b0-f5e7-11e6-8104-30f290fb719f.png)

    ### Version information

    - **Platform**: web (in-browser)

    For the web app:

    - **Browser**: Chrome 56
    - **OS**: Windows
    - **URL**: riot.im/develop

    Contributor guide

    Open the contributing guide

    Assessment

    This issue has not been assessed yet.

    Get new issues in your inbox

    A short digest of beginner-friendly GitHub issues.