@@ -72,6 +72,8 @@ pub async fn export_document(
7272 let gpu_raster = Raster :: < GPU > :: new_gpu ( image_texture. texture . as_ref ( ) . clone ( ) ) ;
7373 let cpu_raster: Raster < CPU > = gpu_raster. convert ( Footprint :: BOUNDLESS , wgpu_executor) . await ;
7474 let ( data, width, height) = cpu_raster. to_flat_u8 ( ) ;
75+ // Explicitly drop texture to make sure it lives long enough
76+ std:: mem:: drop ( image_texture) ;
7577
7678 // Encode and write raster image
7779 write_raster_image ( output_path, file_type, data, width, height, transparent) ?;
@@ -200,8 +202,10 @@ pub async fn export_gif(
200202 let ( data, img_width, img_height) = match result {
201203 TaggedValue :: RenderOutput ( output) => match output. data {
202204 RenderOutputType :: Texture ( image_texture) => {
203- let gpu_raster = Raster :: < GPU > :: new_gpu ( image_texture. texture ) ;
205+ let gpu_raster = Raster :: < GPU > :: new_gpu ( image_texture. texture . as_ref ( ) . clone ( ) ) ;
204206 let cpu_raster: Raster < CPU > = gpu_raster. convert ( Footprint :: BOUNDLESS , wgpu_executor) . await ;
207+ // Explicitly drop texture to make sure it lives long enough
208+ std:: mem:: drop ( image_texture) ;
205209 cpu_raster. to_flat_u8 ( )
206210 }
207211 RenderOutputType :: Buffer { data, width, height } => ( data, width, height) ,
0 commit comments