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] On iOS only, .NET 9.0 / SkiaSharp 3.0 SKCanvasView inside a custom control does not draw itself upon first appearance of the first page #2814

Open
1 task done
janne-hmp opened this issue Mar 28, 2024 · 1 comment
Labels

Comments

@janne-hmp
Copy link

Description

On iOS in .NET 9.0 and SkiaSharp 3.0 Preview 2, in game GnollHack, SKCanvasView inside a custom control (called CustomImageButton) does not invalidate its canvas and draw itself when first entering the app on the first page of the app, resulting in a transparent picture, instead of intended graphics. If I open page on the top of the starting page, or interact with the control, then suddenly it properly draws itself. (Turning the screen from landscape to portrait or vice versa, keeps the transparent button, though.) On Android, the control works just fine. Other such buttons on other pages in iOS seem to work fine, so it seems to be something related to the behavior when entering / starting the app.

Code

https://github.com/hyvanmielenpelit/GnollHack

Here's the XAML of CustomImageButton for the sake of ease:

<?xml version="1.0" encoding="UTF-8"?>
<ContentView 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="GnollHackM.CustomImageButton">
  <ContentView.Content>
        <Grid x:Name="customGrid">
            <skia:SKCanvasView x:Name="customCanvasView" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" EnableTouchEvents="false" PaintSurface="CustomCanvasView_PaintSurface" />
            <Button Text="" x:Name="customButton" Clicked="CustomButton_Clicked" BackgroundColor="Transparent" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
        </Grid>
    </ContentView.Content>
</ContentView>

Expected Behavior

Both on iOS and Android, SkiaSharp draws intended button graphics for CustomImageButtons instead of a transparent bitmap when entering / starting the app.

Actual Behavior

On iOS, none of the background images of CustomImageButtons on MainPage get drawn when entering the page (first page in the app). If a page is opened above the buttons or some interaction with the buttons take place, the background is suddenly drawn. On Android, the controls work fine.

Version of SkiaSharp

3.x (Alpha)

Last Known Good Version of SkiaSharp

2.80.x (Deprecated)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Android, iOS

Platform / Operating System Version

Android 14, iOS 17.3.1

Devices

Google Pixel 6a, iPad 11,7

Relevant Screenshots

ScreenWhenEnteringTheApp
CorrectScreenAfterOpeningSettingsScreenAndComingBack

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@janne-hmp
Copy link
Author

This may also have something to do with the fact that these controls fade in using animation functionality on opacity at the start of the game. Perhaps SkiaSharp does not realize that on iOS and does not draw itself for that reason.

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

No branches or pull requests

1 participant