Skip to content

[REGRESSION, 3.116.1, Android] SKGLView PaintSurface event is not always on the main thread in .NET MAUI #3287

Open
@janne-hmp

Description

@janne-hmp

Description

On Android using SkiaSharp 3.116.1 and .NET MAUI 9.0.50, SKCanvasView seems to always call PaintSurface event from the main thread, but SKGLView does not: SKGLView's PaintSurface method seems to be quite often on a thread other than the main thread. In Xamarin with SkiaSharp 2.88.8, the PaintSurface seemed to be always called from the main thread with both SKGLView and SKCanvasView. Not sure if this is an intended feature or change in MAUI, but it can cause unexpected crashes if the PaintSurface method utilizes information from UI components or resources shared with the UI or main thread. In any case, this makes using SKGLView much harder than SKCanvasView in MAUI, compared to the situation in Xamarin.

Code

This relates to SKGLView in general, so no code here.

Expected Behavior

When using SKGLView, PaintSurface is always called from the MainThread.

Actual Behavior

When using SKGLView, PaintSurface is called from other threads than the MainThread.

Version of SkiaSharp

3.116.0 (Current)

Last Known Good Version of SkiaSharp

2.88.9 (Previous)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Android

Platform / Operating System Version

Android 15

Devices

Google Pixel 6a, Samsung SM-P615

Relevant Screenshots

No response

Relevant Log Output

I just tested the situation with MainThread.IsMainThread function and it returns false.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions