unoplatform/uno · error · NotSupportedException
Failed to load animation: {sourceUri}
Error message
Failed to load animation: {sourceUri} What it means
Thrown when TryLoadDownloadJson(sourceUri, ct) returns null, i.e. the Lottie JSON could not be downloaded or read from the given UriSource at all (as opposed to error 20 where bytes were obtained but unparseable). It is a NotSupportedException indicating the source resolution itself failed.
Source
Thrown at src/AddIns/Uno.UI.Lottie/LottieVisualSource.Skottie.cs:146
}
SetAnimation(animation);
if (_playState != null)
{
var (fromProgress, toProgress, looped) = _playState;
Play(fromProgress, toProgress, looped);
}
}
catch (Exception ex)
{
throw new InvalidOperationException("Failed load the animation", ex);
}
}
}
else
{
throw new NotSupportedException($"Failed to load animation: {sourceUri}");
}
// Force layout to recalculate
player.InvalidateMeasure();
player.InvalidateArrange();
if (_playState != null)
{
var (fromProgress, toProgress, looped) = _playState;
Play(fromProgress, toProgress, looped);
}
else if (player.AutoPlay)
{
Play(0, 1, true);
}
}
View on GitHub (pinned to 0418340488)
Solutions
- Confirm the asset exists at the packaged location: for ms-appx ensure Build Action is appropriate and the file is in the output; log sourceUri before the call.
- If remote, verify the URL returns 200 in a browser and that CORS headers allow the host (especially under WASM).
- Check network connectivity / proxy settings when fetching remote Lottie at runtime.
- Ensure UriSource is an absolute Uri; relative Uris may not resolve in TryLoadDownloadJson.
- Handle NotSupportedException around AnimatedVisualPlayer.Source assignment to degrade gracefully.
Example fix
// before
<Lottie:LottieVisualSource UriSource="ms-appx:///Assets/anim.json"/>
// after — verify the asset is packaged and absolute
var src = new LottieVisualSource { UriSource = new Uri("ms-appx:///Assets/anim.json", UriKind.Absolute) };
player.Source = src; Defensive patterns
Strategy: validation
Validate before calling
// Verify the UriSource resolves before assigning
if (!await TryDownloadAsync(sourceUri))
{
Log.Error($"Lottie source unreachable: {sourceUri}");
ShowFallback();
return;
} Type guard
async Task<bool> UriIsReachable(Uri u)
{
try { using var r = await new HttpClient().GetAsync(u); return r.IsSuccessStatusCode; }
catch { return false; }
} Try / catch
try { player.Source = lottieSource; }
catch (NotSupportedException ex) when (ex.Message.Contains("Failed to load animation"))
{ ShowFallback(); } Prevention
- Use absolute Uris for Lottie sources.
- Confirm ms-appx assets are packaged (correct Build Action).
- For remote Lottie, ensure CORS allows the host under WASM.
When it happens
Trigger: UriSource points to a remote URL that 404s, a network failure occurs, the ms-appx:/// path does not resolve to an embedded asset, or the cancellation token cancels mid-download. _lastSource differs from sourceUri so the download branch is entered, and TryLoadDownloadJson yields null.
Common situations: Wrong ms-appx asset path (file not added as Bundle/Content); CORS or connectivity failure fetching a remote Lottie URL under WebAssembly; relative URI not resolved correctly; asset stripped by the platform packager; typo in the UriSource string.
Related errors
- Failed to load animation.
- Failed load the animation
- NotImplemented_GetFormattedString
- The staged content was released when the download was trigge
- value
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/d6d192801ab2014a.
Report an issue: GitHub.