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

[BUG] "Handler not found for view SkiaSharp.Views.Maui.Controls.SKGLView." #2860

Closed
1 task done
ToolmakerSteve opened this issue May 16, 2024 · 4 comments
Closed
1 task done

Comments

@ToolmakerSteve
Copy link

ToolmakerSteve commented May 16, 2024

Description

Target Windows Machine, get Unhandled Exception:

"Handler not found for view SkiaSharp.Views.Maui.Controls.SKGLView."

-- Other details --

.csproj targetframework: net8.0-windows10.0.19041.0

VS Community 17.9.7 on Windows 11 Home

Tested with Microsoft.Maui.Controls 8.0.40 +

SkiaSharp.Views & SkiaSharp.Views.Maui Controls:

  • latest stable 2.88.8, then tried

  • latest preview 3.0.0-preview.3.1

  • Did not try on earlier versions of Maui or these SkiaSharp nugets.

  • Before Maui, we used OpenTK.GLWpfControl with SkiaSharp.Views.WPF under .Net Framework. That older version of our app builds and runs on this PC without problems.

Code

Maui App template. Modified to add SKGLView. Removed AppShell and other unneeded stuff.

ToolmakerSteve/MauiAppWithSKGLView

        public MainPage()
        {
            InitializeComponent();

            MainThread.BeginInvokeOnMainThread(async () =>
            {
                await Task.Delay(2000);
                // UNCOMMENT these lines to test adding SKGLView in code.
                //var skv = new SKGLView() { WidthRequest = 300, HeightRequest = 300 };
                // Below line: Exception: "Handler not found for view SkiaSharp.Views.Maui.Controls.SKGLView."
                //layout.Children.Add(skv);
            });
        }

You can also share some XAML:

<ContentPage
    xmlns:sk="clr-namespace:SkiaSharp.Views.Maui.Controls;assembly=SkiaSharp.Views.Maui.Controls"
    ...

    <VerticalStackLayout x:Name="layout" Padding="30,0" Spacing="25">
        <!-- Exception: "Handler not found for view SkiaSharp.Views.Maui.Controls.SKGLView."  -->
        <sk:SKGLView WidthRequest="500" HeightRequest="300" BackgroundColor="Green" />
    </VerticalStackLayout>

Expected Behavior

A Window containing an SKGLView.

Actual Behavior

Unhandled Exception:

"Handler not found for view SkiaSharp.Views.Maui.Controls.SKGLView."

Version of SkiaSharp

Other (Please indicate in the description)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Windows 11 Home.

Did not test elsewhere.

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@mattleibow
Copy link
Contributor

mattleibow commented May 20, 2024

I downloaded your sample and noticed the .UseSkiaSharp() line is missing from your MauiProgram.cs:

image

@daltzctr
Copy link

daltzctr commented May 23, 2024

Nevermind. Needs preview version to work

@ToolmakerSteve
Copy link
Author

ToolmakerSteve commented May 24, 2024

I downloaded your sample and noticed the .UseSkiaSharp() line is missing from your MauiProgram.cs:

That fixes it. I completely forgot about that.

Sorry about the false alarm.

Hopefully this will help others who make a similar mistake.

@mattleibow
Copy link
Contributor

I need to put this in the docs... Not sure if there are any docs for setting up a maui with skia app.

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

3 participants