Chatterino / chatterino2

Chat client for https://twitch.tv
MIT License
1.97k stars 442 forks source link

refactor: load images in workers and push immediately #5431

Closed Nerixyz closed 1 month ago

Nerixyz commented 1 month ago

This PR refactors the image loading (and cleans up some of the code there, so make sure you disable whitespace when viewing the diff). It moves the loading of frames to a worker thread (the one we get from the network request).

Since the only work left is to assign the parsed frames to the image, this can be done in one go (no more queue). Once the frames are loaded, they are immediately pushed.

Technically, if many images load between two gui-thread-event-loop iterations, this could bloat the event-queue. Although I haven't measured, I don't think this is a bottleneck. When notifying channels, however, updates are batched to at most one per iteration.