learningequality / kolibri

Kolibri Learning Platform: the offline app for universal education
https://learningequality.org/kolibri/
MIT License
779 stars 647 forks source link

Channel thumbnails can cause extreme slowdown of channel API call #12502

Closed rtibbles closed 1 month ago

rtibbles commented 2 months ago

Observed behavior

When loading the available channels in Kolibri, the inclusion of the thumbnails in the API response can cause it to be very large, blocking page rendering. Without the thumbnails, a 1.6MB API payload can be reduced to less than 6KB. This is a significantly larger saving than just gzipping the payload, which reduces by about 25%.

Expected behavior

Instead of returning the thumbnails as base64 encoded images, the internal channelmetadata API endpoint should return a URL for a new view that reads the contents of the the thumbnail column of the channel metadata table, and returns the content as a file response.

This will allow the thumbnails to be loaded in a non-blocking way allowing significantly faster load times wherever channels are loaded.

N.B. For now this should not affect the public channel metadata endpoints, as older Kolibris will still expect the base64 encoded version. A follow up issue will be filed to better handle this for the public APIs.

User-facing consequences

Getting rid of timeouts on the library page when users have lots of channels with large thumbnails.

Context

Kolibri version 0.16.2, with many channels with large thumbnails installed.

thesujai commented 2 months ago

@rtibbles May i work on this?

rtibbles commented 2 months ago

Sure - happy to see you give it a go!

rtibbles commented 1 month ago

Fixed in #12530 - thank you @thesujai !