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

Using SKSwapChainPanel nuget package V3-Preview 2.1 in WinUI3 Throws an Exception: AccessViolationException #2803

Open
1 task done
AmitParmar2005 opened this issue Mar 23, 2024 · 12 comments

Comments

@AmitParmar2005
Copy link

AmitParmar2005 commented Mar 23, 2024

Description

Hi Friends,

First of all thank you so much for porting SKSwapChainPanel to WinUI3. I have been waiting for it for very long time.

To test new functionalities, I created a simple program which uses SKSwapChainPanel. I have installed Skiasharp.Views.WinUI (3.0.0-preview 2.1) nuget package. But, when I run the application, I get System.AccessViolationException: 'Attempted to read or write protected memory.

image

Seems, I have installed all required packages.

image

I have also build and install angle with vcpkg. Without any luck.

Can somebody please help me what I am missing here? Please let me know if you want me to upload project.

Thanks and Regards,
Amit

Code

The best way to share code for larger projects is a link to a GitHub repository: https://github.com/user/repo/tree/bug-123

But, you can also share a short block of code here:

// some C# code here

You can also share some XAML:

<!-- xaml code here -->

<Grid Name="mygrid">
    <StackPanel>
        <skia:SKSwapChainPanel Name="canvas" Height="200" Width="200"/>
    </StackPanel>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
    </StackPanel>
</Grid>

Expected Behavior

I should not throw an expception

Actual Behavior

Throws an exception

Version of SkiaSharp

3.x (Alpha)

Last Known Good Version of SkiaSharp

2.88.2 (Previous)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Windows 10

Devices

Windows 10 Laptop

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 Apr 8, 2024

You should not install any other ANGLE library - it is included in the package.

Let me know if removing ANGLE and rebuilding after deleting the bin/obj fixes this.

@TopperDEL
Copy link

TopperDEL commented Apr 15, 2024

I'm running into the same problem. All I did was: create a new WinUI-project (in this case a Uno-App), add the SkiaSharp.Views.Uno.WinUI-package and the following code:

xmlns:skia="using:SkiaSharp.Views.Windows"
<skia:SKSwapChainPanel PaintSurface="SKSwapChainPanel_PaintSurface" Height="200" Width="200"/>

Then I get the exact same error as mentioned above.

@AmitParmar2005
Copy link
Author

I was able to make it running. Dont install Uno package. Install WinUI Package. Here's the screenshot. Please let me know if you want me to upload entire project.

image

@TopperDEL
Copy link

Thanks @AmitParmar2005 - but that does not seem to help in my case. I don't get the SKSwapChainPanel to work on Uno. I tried adding SkiaSharp itself, switchting to preview 2.1 (like you have above) - but none works. I always get the error above as soon as I add an SKSwapChainPanel-Control to my page.

@AmitParmar2005
Copy link
Author

Try the attached zip file. Its very simple working sample. Let me know if you still have any issues.

WinUI3_SKSwap_Test.zip

@TopperDEL
Copy link

That works here, too. But I don't get it to work together with Uno-platform.

@AmitParmar2005
Copy link
Author

I am not sure about Uno-Platform. I never worked on it. I will check it out and get back to you.

@TopperDEL
Copy link

Awesome, thanks!

@mattleibow
Copy link
Contributor

@TopperDEL are you able to create a sample and more info on how you are using Uno? I have not really been working on Uno views much these days, so maybe the Uno team has more info. @jeromelaban thoughts?

@TopperDEL
Copy link

I just created a new Uno-App (5.2) and tried to add SkiaSharp.Views.Uno.WinUI to the project. But Nuget won't let me. It says that the package is explicitly referenced by a SDK. So it seems I cannot use the pre-release 3.0.0-preview.3.1 together with Uno?
So I cannot try the new SwapChainPanel.

My previous attempt was with the previous Uno-version, that where not single-prject-based. I could add the Skia-prerelease-version - but maybe it led to my issue during runtime, as it got mixed up with the binaries or so?

@jeromelaban: Do you know if it would be possible (and how) to use SkiaSharp-preview-version (3.0.0-*) together with a Uno-app (5.2)?

@jeromelaban
Copy link
Contributor

Uno Platform 5.2 is not compatible with SkiaSharp v3, but 5.3 will be. You can try it out with by upgrading to the latest prerelease bits.

Overall though, SKSwapChainPanel is supported on iOS, Android and WebAssembly. Catalyst does not have the right setup yet (Metal should be used) and Desktop target must SKXamlCanvas for now. For desktop, we're making changes here to provide unoplatform/uno#16621 a canvas pass-through for performance.

@TopperDEL
Copy link

Thanks, @jeromelaban! Then it is not of immediate use for me as I need to target Windows and macOS. Let's see how #16621 goes. :)

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

4 participants