jmbowman1107 / Particle.Maui

A MAUI library to display particles e.g. confetti. Should work on all platforms.
MIT License
7 stars 0 forks source link

Particle.Maui not working on .NET 7.0 .NET Android (works fine on Windows) #1

Open Bebz0r opened 1 year ago

Bebz0r commented 1 year ago

Hello there,

I'm having trouble using Particle.Maui on Android : it works flawlessly on Windows but nothing is shown on Android.

Here is what I did : Created a new MAUI .NET 7.0 App Added the NuGet Particle.MAUI 1.0.3 Added the .UseSkiaSharp() in the MauiProgram.cs Added the namespace to the mainpage.xaml : xmlns:particle="clr-namespace:Particle.Maui;assembly=Particle.Maui" Added the particle viewport Launched on Windows : works Launched on Android : do not work : the app is launched but no particles appear - no error messages

The code is fairly simple : MauiProgram.cs using Microsoft.Extensions.Logging; using SkiaSharp.Views.Maui.Controls.Hosting;

namespace TestParticles;

public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() .UseSkiaSharp() .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); });

if DEBUG

    builder.Logging.AddDebug();

endif

    return builder.Build();
}

}

And the MainPage.xaml : <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:particle="clr-namespace:Particle.Maui;assembly=Particle.Maui" x:Class="TestParticles.MainPage">

<Grid VerticalOptions="FillAndExpand"
      BackgroundColor="White"
      Margin="0 ,0, 0, 5">

<particle:ParticleView x:Name="MyParticleCanvas"
                        IsActive="True"
                        IsRunning="True"
                        HasFallingParticles="True"
                        FallingParticlesPerSecond="20"
                        Margin="0, 20"
                        VerticalOptions="FillAndExpand"
                        HorizontalOptions="FillAndExpand"/>
</Grid>

The MainPage.cs is nearly empty : namespace TestParticles;

public partial class MainPage : ContentPage { // Started a new .NET MAUI Projet (.NET 7 - same result with .NET 6) // Added the NuGet Particle.MAUI 1.0.3 // Added the .UseSkiaSharp() in the MauiProgram.cs // Added the namespace to the mainpage.xaml : xmlns:particle="clr-namespace:Particle.Maui;assembly=Particle.Maui" // Added the particle viewport / <particle:ParticleView x:Name="MyParticleCanvas" FallingParticlesPerSecond="25.0" IsActive="True" IsRunning="True" HasFallingParticles="True" Margin="0, 20" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" InputTransparent="True"/> / public MainPage() { InitializeComponent(); }

I created a GitHub example : https://github.com/Bebz0r/TestParticles

I tried with version 1.0.2 and 1.0.3 to no avail.

Any ideas ?

Cheers, Beb

Bebz0r commented 1 year ago

Wait up, it may be something linked to my device : animations suddently stopped to work on my device, and this for all MAUI .NET applications, even the ones previously installed. No idea why.

Bebz0r commented 1 year ago

That was my fault, my device was in battery saver mode, and animations don't play if that's the case. So this is not an issue. Sorry about that.