mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 17:49:52 +00:00
show decode errors reliably.
This commit is contained in:
@@ -155,7 +155,7 @@ export default class App extends Component<Props, State> {
|
|||||||
// changed.
|
// changed.
|
||||||
if (source !== prevState.source || image.encoderState !== prevImage.encoderState) {
|
if (source !== prevState.source || image.encoderState !== prevImage.encoderState) {
|
||||||
if (prevImage.downloadUrl) URL.revokeObjectURL(prevImage.downloadUrl);
|
if (prevImage.downloadUrl) URL.revokeObjectURL(prevImage.downloadUrl);
|
||||||
this.updateImage(i);
|
this.updateImage(i).catch(console.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,13 @@ export default class App extends Component<Props, State> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bmp = await createImageBitmap(file);
|
let bmp;
|
||||||
|
try {
|
||||||
|
bmp = await createImageBitmap(file);
|
||||||
|
} catch (err) {
|
||||||
|
this.setState({ error: `Encoding error (type=${image.encoderState.type}): ${err}` });
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
images = this.state.images.slice() as [EncodedImage, EncodedImage];
|
images = this.state.images.slice() as [EncodedImage, EncodedImage];
|
||||||
|
|
||||||
@@ -243,7 +249,7 @@ export default class App extends Component<Props, State> {
|
|||||||
loadedCounter: loadingCounter,
|
loadedCounter: loadingCounter,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setState({ images, error: '' });
|
this.setState({ images });
|
||||||
}
|
}
|
||||||
|
|
||||||
render({ }: Props, { loading, error, images }: State) {
|
render({ }: Props, { loading, error, images }: State) {
|
||||||
|
|||||||
Reference in New Issue
Block a user