-
Notifications
You must be signed in to change notification settings - Fork 540
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
Implement SKGLView
for .NET MAUI
#2598
Conversation
0df2a39
to
1fb1354
Compare
Hi Matthew, are there any plans to have a common hw accelerated view for a MAUI app for Android, iOS, Windows and Mac? If not possible, how could I use an hw accelerated view on Windows? (and maybe a new one for Mac)? |
Definitely would like this to work on all the platforms being targeted. Windows, Mac, etc. |
@mattleibow I've sort of tested implementation of SKGLView on ios and android. I needed metal on iOS, so I've just replaced native view for SKGLViewHandler.iOS and seem to be fine, could be considered while implementing universal HW accelerated view. All seems to be much smoother than CPU rendering for my usecase, thank you for the solution. However I've noticed following issue on android: Here when setting SKGLViewHandler.Android.cs public static void MapHasRenderLoop(SKGLViewHandler handler, ISKGLView view)
{
handler.PlatformView.RenderMode = view.HasRenderLoop
? Rendermode.Continuously
: Rendermode.WhenDirty;
} I checked following handler function, and seems you're using wrong method here: // Mapper actions / properties
public static void OnInvalidateSurface(SKGLViewHandler handler, ISKGLView view, object? args)
{
handler.PlatformView?.Invalidate();
} According to MSDN:
Here's the change I've applied according to MSDN and it seem to work fine: public static void OnInvalidateSurface(SKGLViewHandler handler, ISKGLView view, object? args)
{
handler.PlatformView?.RequestRender();
} |
1fb1354
to
4cb238b
Compare
4cb238b
to
16c8828
Compare
16c8828
to
d79b830
Compare
Thanks @bogdan799! Your findings helped. |
- Mac Catalyst does not support OpenGL and will need a new Metal-based view - Tizen needs the support in the native view
d79b830
to
ce2520b
Compare
Mac Catalyst has CAOpenGLLayer. You can have a UIView backed by CAOpenGLLayer and render OpenGL in the layer so that you don't have to mess with Metal. |
I am not sure if it is exposed in the .NET bindings. They left out all the deprecated APIs for Mac Catalyst :( |
@mattleibow I am getting the exception "Handler not found for view SkiaSharp.Views.Maui.Controls.SKGLView." in a fresh .Net Maui App project, targetting "Windows Machine", with an SKGLView added. The exception occurs at run time. Commenting out the SKGLView line, the app runs w/o error. Added these two lines in appropriate places in MainPage.xaml:
Or alternatively adding in code behind after a delay:
-- 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:
Is this expected to work in Maui 8, or do I need a preview version of .Net Maui 9? Should I create a new issue and/or upload a sample project? |
Please open a new issue with a repro sample. GL should be working. |
@mattleibow - is there a plan to backport #2598 (Maui SKGLView fix) on Windows to 2.88.x? Updating my client from .Net Framework 4.5 to .Net 8. We've successfully updated on iOS and Android. On Windows .Net 8, SkiaSharp 2.88.8 or .9, we've got everything EXCEPT OpenGL working. Using Maui SKCanvasView. I made a new Maui app. Added SkiaSharp 2.88.9. Remembered to do "UseSkiaSharp()". Still get "Handler not found for view SkiaSharp.Views.Maui.Controls.SKGLView.". Updating to SkiaSharp 3.118.0.0 preview, it works. BUT this app is used in a production situation where failures must be very rare. So I can't use anything that isn't considered a stable release. |
Description of Change
Bugs Fixed
API Changes
None.
Behavioral Changes
None.
Required skia PR
None.
PR Checklist