From 0387a7857418dc94056f73f65e5a0387f08001b1 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 22 Oct 2020 23:52:26 -0700 Subject: [PATCH] show error message when preload can't build movies Not sure why movie clip building is failing! But it happened outside our try-catch, so it left us in an infinite spinner state. The repro item is the Spring Topiary Garden Background! --- src/app/components/OutfitPreview.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/app/components/OutfitPreview.js b/src/app/components/OutfitPreview.js index 6dbcf59..4c66c46 100644 --- a/src/app/components/OutfitPreview.js +++ b/src/app/components/OutfitPreview.js @@ -340,13 +340,24 @@ export function usePreloadLayers(layers) { if (canceled) return; - const newLayersHaveAnimations = assets.some( - (a) => - a.type === "movie" && - hasAnimations(buildMovieClip(a.library, a.libraryUrl)) - ); + let movieClips; + try { + movieClips = assets + .filter((a) => a.type === "movie") + .map((a) => buildMovieClip(a.library, a.libraryUrl)); + } catch (e) { + console.error("Error building movie clips", e); + assetPromises.forEach((p) => { + if (p.cancel) { + p.cancel(); + } + }); + setError(e); + return; + } + + setLayersHaveAnimations(movieClips.some(hasAnimations)); setLoadedLayers(layers); - setLayersHaveAnimations(newLayersHaveAnimations); }; loadAssets();