2 months ago
7cd7c73* perf(library): serve cover-art thumbnails through the asset protocol The library grid fetched every 80px WebP derivative over IPC and pushed the bytes through a ref-counted blob-URL cache: one round trip, one Vec<u8> copy, one Blob allocation, and one cache entry per visible row, repeated as rows recycle during scrolling. Serve the derivative file directly instead. Song gains artwork_thumb_path, and CoverArtThumbnail renders convertFileSrc(path). The grid now issues zero IPC calls for cover art. What makes this safe is that derivative filenames are content-addressed (thumb_<sha256>_80.webp), so a replaced cover arrives as a different path - the WebView may cache the image freely with no busting scheme. get_cover_art stays: it is still the only source for the SQLite BLOB original, and it remains the lazy repair path. An <img> that fails to load falls back to it, which is what regenerates a missing derivative. Only the thumb migrates. Carrying a second path for the 256px preview would add ~126 bytes per song to every library payload to save one IPC call per *song change* - the preview backs a single ambience image, not a grid, so it keeps the existing path. The asset scope is granted where the paths are handed out rather than at library activation: the scope is in-memory and the library root is user-relocatable, so a future activation path cannot forget it, and allow_directory inserts into a HashSet so repeating it is free. No loading="lazy": f4bc3ca removed it because desktop WebViews left blob-backed thumbnails unpainted with deferred decoding, and the library list is virtualized, so off-screen rows are not in the DOM to lazy-load anyway. That rationale comment was lost in a later refactor and is restored. Closes #264 * fix(library): absolutize thumbnail paths in every Song-returning command Only get_library and search_library ran the rewrite, so a song returned by import, cover-art extraction, a metadata edit, or an instrumental or language toggle carried a still-relative path into the store. The grid then issued an asset request the app cannot serve and fell back to IPC - correct image, wasted request, and the optimization silently off for that song until the next library load.
Parentab0f004