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!
This commit is contained in:
Emi Matchu 2021-09-02 19:09:27 -07:00
parent fc52439387
commit 781034a568

View file

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