From 781034a568a8c89729580e8e5bad4b26c4e04e94 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 2 Sep 2021 19:09:27 -0700 Subject: [PATCH] Oops, don't crash if animation image fails Whoops, `Promise.race` isn't quite what I wanted here. This meant that, if the image promise _fails_ before the movie _succeeds_, the outfit would crash even though it doesn't need to. (And this was happening too often, due to a bug in /api/assetImage!) Now, we accept whichever _successful_ result loads first, or reject if they _both_ fail. I tested this by having /api/assetImage always throw, and confirmed that it crashed the outfit before this change, and no longer does after this change! --- src/app/components/OutfitPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/OutfitPreview.js b/src/app/components/OutfitPreview.js index e224a0f..c542219 100644 --- a/src/app/components/OutfitPreview.js +++ b/src/app/components/OutfitPreview.js @@ -417,7 +417,7 @@ export function usePreloadLayers(layers) { // The minimal asset for the movie case is *either* the image *or* // the movie, because we can start rendering when either is ready. minimalAssetPromises.push( - Promise.race([imageAssetPromise, movieAssetPromise]) + Promise.any([imageAssetPromise, movieAssetPromise]) ); } else { minimalAssetPromises.push(imageAssetPromise);