Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lottie animation not visible on Page from ServiceProvider #147

Closed
PureWeen opened this issue Oct 13, 2022 · 13 comments · Fixed by #200
Closed

Lottie animation not visible on Page from ServiceProvider #147

PureWeen opened this issue Oct 13, 2022 · 13 comments · Fixed by #200
Labels

Comments

@PureWeen
Copy link

Description

When Page with Lottie animation is created from ServiceProvider, then Lottie animation is not visible

Steps to Reproduce

In file App.xaml.cs there are two examples. One i working fine. Second not

Link to public reproduction project repository

https://github.com/MarMarIV/MauiLottieApp

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows

Affected platform versions

Any version

Did you find any workaround?

Unfortunately, no

Relevant log output

No response

@PureWeen PureWeen added the bug label Oct 13, 2022
@mattleibow mattleibow changed the title Lottie animation not visible on Page from ServiceProvider[BUG] Lottie animation not visible on Page from ServiceProvider Oct 17, 2022
@MarMarIV
Copy link

Is there any progress of this bug?

@Syed-RI
Copy link

Syed-RI commented May 2, 2023

bump @mattleibow

@Syed-RI
Copy link

Syed-RI commented May 2, 2023

Any workaround anyone?

@Syed-RI
Copy link

Syed-RI commented May 2, 2023

Sadly, moved back to ActivityIndicator

@alextorres50
Copy link

alextorres50 commented May 11, 2023

any update? @PureWeen Any alternative solution? @jfversluis

@Syed-RI
Copy link

Syed-RI commented May 11, 2023

bump @mattleibow

@gabsamples6
Copy link

@mattleibow is lottie still supported in maui? it does not work in ios at all

@MarMarIV
Copy link

I originally started this issue, so I'll include a possible workaround:

Copy these listed resources and paste them into your app. Rendering should start working

https://github.com/mono/SkiaSharp.Extended/blob/0ff98b0080b043e7e12aff3912f496f708acfd25/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKLottieViewResources.shared.xaml#L7C1-L20C59

@Syed-RI
Copy link

Syed-RI commented Jul 31, 2023

Ok but is there an explanation as to why this would work? PS Im yet to try the solution myself

@gabsamples6
Copy link

@MarMarIV copy to any resource dictionary at startup ?

@mattleibow
Copy link
Contributor

I had a look at this and I think I see what is happening. The lottie view uses some styles that are in the class library. Typically if you add the control to a page that is not from the services, the view will register the styles it needs before it is constructed, so it can access them.

However, if the page comes from the services as in this issue, then the page and the lottie view is constructed before the app has completed construction - because it is part of the construction.

A workaround is to include the themes and styles yourself in your App.xaml:

<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:MauiLottieApp"
             xmlns:themes="clr-namespace:SkiaSharp.Extended.UI.Controls.Themes;assembly=SkiaSharp.Extended.UI"
             x:Class="MauiLottieApp.App">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!-- ... existing styles ... -->
                <themes:SKLottieViewResources /> <!-- this is the new style from the library -->
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

This is actually a manifestation of dotnet/maui#9612. I have to try and find a good place to add the themes, but it is not great.

@mattleibow
Copy link
Contributor

I think I have a workaround for now. I can detect when the Window changes and at that point the app is ready and the control is not yet styled. If I register my themes then it works again.

@Syed-RI
Copy link

Syed-RI commented Aug 23, 2023

woowhooo! 🎉

@mattleibow thanks a lot for your hard work! Does 2.0.0-preview.70 contains this workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants