From a7e9d52efd1dba23a43f13d0eb9bb2236d1de74c Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 21 Feb 2026 03:27:59 +0100 Subject: fix image transcode on evloop thread --- server/src/ui/assets.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'server/src') diff --git a/server/src/ui/assets.rs b/server/src/ui/assets.rs index c956672..91bb5e2 100644 --- a/server/src/ui/assets.rs +++ b/server/src/ui/assets.rs @@ -8,6 +8,7 @@ use crate::{request_info::RequestInfo, responders::cache::CacheControlImage}; use anyhow::Context; use rocket::{get, http::ContentType}; use std::path::PathBuf; +use tokio::task::spawn_blocking; pub const AVIF_QUALITY: u32 = 70; pub const AVIF_SPEED: u8 = 5; @@ -23,9 +24,12 @@ pub async fn r_image( // fit the resolution into a finite set so the maximum cache is finite too. let width = 2usize.pow(size.clamp(128, 2048).ilog2()); - let encoded = + let encoded = spawn_blocking(move || { jellytranscoder::image::transcode(&ri.state.cache, &path, AVIF_QUALITY, AVIF_SPEED, width) - .context("transcoding asset")?; + .context("transcoding asset") + }) + .await + .unwrap()?; Ok((ContentType::AVIF, CacheControlImage(encoded))) } -- cgit v1.3