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:
Sophie Herold 2024-07-29 03:32:13 +02:00
parent 9feef50c01
commit c3547f82fc
4 changed files with 43 additions and 24 deletions

View file

@ -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)]