{"record":{"id":"d6d192801ab2014a","repo":"unoplatform/uno","slug":"failed-to-load-animation-sourceuri","errorCode":null,"errorMessage":"Failed to load animation: {sourceUri}","messagePattern":"Failed to load animation: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/AddIns/Uno.UI.Lottie/LottieVisualSource.Skottie.cs","lineNumber":146,"sourceCode":"\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tSetAnimation(animation);\n\n\t\t\t\t\t\t\t\t\tif (_playState != null)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tvar (fromProgress, toProgress, looped) = _playState;\n\t\t\t\t\t\t\t\t\t\tPlay(fromProgress, toProgress, looped);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcatch (Exception ex)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tthrow new InvalidOperationException(\"Failed load the animation\", ex);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow new NotSupportedException($\"Failed to load animation: {sourceUri}\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Force layout to recalculate\n\t\t\t\t\t\tplayer.InvalidateMeasure();\n\t\t\t\t\t\tplayer.InvalidateArrange();\n\n\t\t\t\t\t\tif (_playState != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar (fromProgress, toProgress, looped) = _playState;\n\t\t\t\t\t\t\tPlay(fromProgress, toProgress, looped);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (player.AutoPlay)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tPlay(0, 1, true);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/AddIns/Uno.UI.Lottie/LottieVisualSource.Skottie.cs#L128-L164","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n<Lottie:LottieVisualSource UriSource=\"ms-appx:///Assets/anim.json\"/>\n\n// after — verify the asset is packaged and absolute\nvar src = new LottieVisualSource { UriSource = new Uri(\"ms-appx:///Assets/anim.json\", UriKind.Absolute) };\nplayer.Source = src;","handlingStrategy":"validation","validationCode":"// Verify the UriSource resolves before assigning\nif (!await TryDownloadAsync(sourceUri))\n{\n    Log.Error($\"Lottie source unreachable: {sourceUri}\");\n    ShowFallback();\n    return;\n}","typeGuard":"async Task<bool> UriIsReachable(Uri u)\n{\n    try { using var r = await new HttpClient().GetAsync(u); return r.IsSuccessStatusCode; }\n    catch { return false; }\n}","tryCatchPattern":"try { player.Source = lottieSource; }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"Failed to load animation\"))\n{ ShowFallback(); }","preventionTips":["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."],"tags":["lottie","download","uri","assets","network","uno-platform"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}