Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't throw error if GIF loading is aborted #1346

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/gif/src/GifForDevelopment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const GifForDevelopment = forwardRef<

useEffect(() => {
let done = false;
let aborted = false;
const {prom, cancel} = parseWithWorker(resolvedSrc);
const newHandle = delayRender('Loading <Gif /> with src=' + resolvedSrc);

Expand All @@ -52,6 +53,10 @@ export const GifForDevelopment = forwardRef<
continueRender(id);
})
.catch((err) => {
if (aborted) {
return;
}

if (currentOnError.current) {
currentOnError.current(err);
} else {
Expand All @@ -61,6 +66,7 @@ export const GifForDevelopment = forwardRef<

return () => {
if (!done) {
aborted = true;
cancel();
}

Expand Down
6 changes: 6 additions & 0 deletions packages/gif/src/GifForRendering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(
useEffect(() => {
const controller = new AbortController();
let done = false;
let aborted = false;
const newHandle = delayRender('Loading <Gif /> with src=' + resolvedSrc);

parseGif({controller, src: resolvedSrc})
Expand All @@ -51,6 +52,10 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(
continueRender(id);
})
.catch((err) => {
if (aborted) {
return;
}

if (currentOnError.current) {
currentOnError.current(err);
} else {
Expand All @@ -60,6 +65,7 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(

return () => {
if (!done) {
aborted = true;
controller.abort();
}

Expand Down