svg: Handle errors for additional tiles gracefully
Some SVGs run into issues when zooming in due to memory limitations. These errors are now ignored and the existing tiles are used. Issue #358
This commit is contained in:
parent
9feef50c01
commit
c3547f82fc
4 changed files with 43 additions and 24 deletions
1
news.d/47.beta/fixed-svg-dont-fail-on-additional-tails
Normal file
1
news.d/47.beta/fixed-svg-dont-fail-on-additional-tails
Normal file
|
|
@ -0,0 +1 @@
|
|||
Don't show error-screen if SVG has been loaded and only the rendering for tiles for other zoom levels fails. Instead, show the already loaded tiles.
|
||||
|
|
@ -116,22 +116,26 @@ impl UpdateSender {
|
|||
let result: Result<(), glycin::ErrorCtx> = f.await;
|
||||
|
||||
if let Err(err) = result {
|
||||
if err.unsupported_format().is_some() {
|
||||
update_sender.send(DecoderUpdate::SpecificError(
|
||||
DecoderError::UnsupportedFormat,
|
||||
));
|
||||
}
|
||||
if err.is_out_of_memory() {
|
||||
update_sender.send(DecoderUpdate::SpecificError(DecoderError::OutOfMemory));
|
||||
} else if matches!(err.error(), glycin::Error::NoLoadersConfigured(_)) {
|
||||
update_sender.send(DecoderUpdate::SpecificError(
|
||||
DecoderError::NoLoadersConfigured,
|
||||
));
|
||||
}
|
||||
update_sender.send(DecoderUpdate::GenericError(err.into()));
|
||||
update_sender.send_error(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_error(&self, err: glycin::ErrorCtx) {
|
||||
if err.unsupported_format().is_some() {
|
||||
self.send(DecoderUpdate::SpecificError(
|
||||
DecoderError::UnsupportedFormat,
|
||||
));
|
||||
}
|
||||
if err.is_out_of_memory() {
|
||||
self.send(DecoderUpdate::SpecificError(DecoderError::OutOfMemory));
|
||||
} else if matches!(err.error(), glycin::Error::NoLoadersConfigured(_)) {
|
||||
self.send(DecoderUpdate::SpecificError(
|
||||
DecoderError::NoLoadersConfigured,
|
||||
));
|
||||
}
|
||||
self.send(DecoderUpdate::GenericError(err.into()));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ impl Svg {
|
|||
updater.clone().spawn_error_handled(async move {
|
||||
log::trace!("Setting up SVG loader");
|
||||
let mut loader = glycin::Loader::new(file);
|
||||
loader.sandbox_selector(glycin::SandboxSelector::FlatpakSpawn);
|
||||
|
||||
loader.cancellable(cancellable.clone());
|
||||
|
||||
|
|
@ -135,14 +136,19 @@ impl Svg {
|
|||
area.height() as u32,
|
||||
);
|
||||
|
||||
let frame = image.specific_frame(frame_request).await?;
|
||||
match image.specific_frame(frame_request).await {
|
||||
Ok(frame) => {
|
||||
let position = (
|
||||
tile_instructions.area.x() as u32,
|
||||
tile_instructions.area.y() as u32,
|
||||
);
|
||||
|
||||
let position = (
|
||||
tile_instructions.area.x() as u32,
|
||||
tile_instructions.area.y() as u32,
|
||||
);
|
||||
|
||||
tiles.push_tile(tiling, position, frame.texture());
|
||||
tiles.push_tile(tiling, position, frame.texture());
|
||||
}
|
||||
Err(err) => {
|
||||
updater.send_error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,9 +112,6 @@ impl imp::LpImage {
|
|||
));
|
||||
}
|
||||
}
|
||||
DecoderUpdate::GenericError(err) => {
|
||||
self.set_error(Some(err));
|
||||
}
|
||||
DecoderUpdate::Animated => {
|
||||
if self.still.get() {
|
||||
// Just load the first frame
|
||||
|
|
@ -131,7 +128,18 @@ impl imp::LpImage {
|
|||
}
|
||||
}
|
||||
DecoderUpdate::SpecificError(err) => {
|
||||
self.set_specific_error(err);
|
||||
if self.obj().is_loaded() {
|
||||
log::warn!("Error occured while loading additional data: {err:?}");
|
||||
} else {
|
||||
self.set_specific_error(err);
|
||||
}
|
||||
}
|
||||
DecoderUpdate::GenericError(err) => {
|
||||
if self.obj().is_loaded() {
|
||||
log::warn!("Error occured while loading additional data: {err:?}");
|
||||
} else {
|
||||
self.set_error(Some(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue