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

MAUI Flyout Locks Map (regression) #2364

Open
nm4568 opened this issue Dec 27, 2023 · 9 comments
Open

MAUI Flyout Locks Map (regression) #2364

nm4568 opened this issue Dec 27, 2023 · 9 comments

Comments

@nm4568
Copy link

nm4568 commented Dec 27, 2023

Mapsui Version
4.1.2

See following issue where this bug was fixed but is repoducible in 4.1.2 using the same sample project provided in Issue # 2000.

#2000

Steps to reproduce

  1. Clone sample project in Issue MAUI Flyout Locks Map #2000
  2. Upgrade Mapsui.Maui to 4.1.2
  3. Follow steps in Issue MAUI Flyout Locks Map #2000
@pauldendulk
Copy link
Member

Thanks for the report. Did you work with a version in which this was fixed? Which version was it?

@nm4568
Copy link
Author

nm4568 commented Dec 30, 2023

I did, - the issue was first reported using v4.0.0-rc.1 and I believe it was fixed in v4.0.0, however, for some reason I can reproduce the issue on all versions (v4.0.0 thru v4.1.2).

I am using a physical iPhone 14 Pro Max (v17.1.2). The device hasn't changed since the issue was first reported, only the iOS version.

I did upgrade to .NET 8 recently - Here are my workloads.

image

@pauldendulk
Copy link
Member

The underlying cause is a bug in SkiaSharp/MAUI. Our fix was a workaround for this problem. I confirmed the problem and reported a bug here: mono/SkiaSharp#2493. You could help us by by posting your problem on that issue. You could help them by providing a minimal reproducible sample (so not using Mapsui but SkiaSharp directly) and post it there.

@nm4568
Copy link
Author

nm4568 commented Dec 30, 2023

Thanks for looking into. I attempted to recreate a minimal reproducible sample but seeing that only the SKTouchAction.Pressed event is firing on iOS. On Windows, I am seeing other ActionTypes, not just Pressed.

Before I submit it, I wanted to see if you could take a quick look at my code to see if i'm missing something?

Repo - https://github.com/nm4568/SkiaSharpSamples

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:skia="clr-namespace:SkiaSharp.Views.Maui.Controls;assembly=SkiaSharp.Views.Maui.Controls"
             x:Class="SkiaSharpSample.MainPage">
<StackLayout>
        <skia:SKCanvasView x:Name="skCanvasView" PaintSurface="View_PaintSurface" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>
        <Label x:Name="DebugLabel"
               FontSize="20"
               HorizontalOptions="Center"
               VerticalOptions="End" />
    </StackLayout>
</ContentPage>

C#

using SkiaSharp;
using SkiaSharp.Views.Maui;
using SKCanvasView = SkiaSharp.Views.Maui.Controls.SKCanvasView;

namespace SkiaSharpSample
{
    public partial class MainPage : ContentPage
    {
        SKBitmap skBitmap;

        public MainPage()
        {
            InitializeComponent();

            skCanvasView.EnableTouchEvents = true;
            skCanvasView.PaintSurface += View_PaintSurface;
            skCanvasView.Touch += SkCanvasView_Touch;
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();

            // Load and render a PNG image using SkiaSharp
            RenderSkiaSharpImage();
        }

        private void RenderSkiaSharpImage()
        {
            // Get the stream of the embedded resource
            var stream = typeof(MainPage).Assembly.GetManifestResourceStream("SkiaSharpSample.Resources.Images.dotnet_bot.png");

            // Create a SKBitmap from the stream
            skBitmap = SKBitmap.Decode(stream);

        }

        private void SkCanvasView_Touch(object? sender, SkiaSharp.Views.Maui.SKTouchEventArgs e)
        {
            switch (e.ActionType)
            {
                case SKTouchAction.Entered:
                    DebugLabel.Text = "Entered";
                    break;
                case SKTouchAction.Pressed:
                    DebugLabel.Text = "Pressed";
                    break;
                case SKTouchAction.Moved:
                    DebugLabel.Text = "Moved";
                    break;
                case SKTouchAction.Released:
                    DebugLabel.Text = "Released";
                    break;
                case SKTouchAction.Cancelled:
                    DebugLabel.Text = "Canceled";
                    break;
                case SKTouchAction.Exited:
                    DebugLabel.Text = "Exited";
                    break;
            }

            // Invalidate the canvas to trigger a redraw
            ((SKCanvasView)sender).InvalidateSurface();
        }

        private void View_PaintSurface(object? sender, SkiaSharp.Views.Maui.SKPaintSurfaceEventArgs e)
        {
            // Get the SKCanvas from the event arguments
            var canvas = e.Surface.Canvas;

            // Clear the canvas
            canvas.Clear(SKColors.White);

            // Draw the SKBitmap onto the canvas
            canvas.DrawBitmap(skBitmap, new SKPoint(0, 0));
        }
    }
}

@pauldendulk
Copy link
Member

This looks good to me but also I am not expert in this particular topic. Note, that by providing a sample you already post a great issue, even if it turns out to be a misunderstanding instead of a bug. @inforithmics do you have any remarks on this?

One thing to take into account it that Mapsui MAUI supports both SKGLView and SKCanvasView. If MapControl.UseGPU = true SKGLView is use, else SKCanvasView. I am not sure what the default is (This is different for different configuration because we prefer SKGLView but it crashed in some platforms). So this sample which uses SKCanvasView corresponds to MapControl.UseGPU = false. You may want to test both in Mapsui.

@nm4568
Copy link
Author

nm4568 commented Jan 2, 2024

I attempted to use the SKGLView and the app immediately crashes on load in the iOS Emulator.

@nm4568
Copy link
Author

nm4568 commented Jan 7, 2024

I have added a post to the SkiaSharp issue thread you posted with the minimal reproducible sample that was created.

mono/SkiaSharp#2493 (comment)

@pauldendulk
Copy link
Member

No reaction yet. You could also post this as a new issue. I see that they are triaging new issues, so at least they will look at it.

Something else, we might go for an entirely different solution in main. If possible we will use MAUI events instead of SkiaSharp events.

@nm4568
Copy link
Author

nm4568 commented Jan 20, 2024

New issue has been posted - mono/SkiaSharp#2722

Thank you!

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

No branches or pull requests

2 participants