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] x86 fonts are corrupted #3122

Open
1 task done
maiad opened this issue Dec 18, 2024 · 5 comments · May be fixed by #3165
Open
1 task done

[BUG] x86 fonts are corrupted #3122

maiad opened this issue Dec 18, 2024 · 5 comments · May be fixed by #3165
Labels

Comments

@maiad
Copy link

maiad commented Dec 18, 2024

Description

After update to 3.116.1 My application works perfectly in Any CPU and x64 profile, but rendering fonts crashes after few seconst in x86 profile. Older nuget version worked perfectly.

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 -->

Expected Behavior

No response

Actual Behavior

No response

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

Windows

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

x64 screen
x32 screen

Relevant Log Output

No response

Code of Conduct

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

Are you using CPU or GPU rendering? Can you attach a repro sample with the code and the font? This issue does not enough information to start testing.

@maiad
Copy link
Author

maiad commented Jan 4, 2025

Failed with GL and without GL
I encountered an issue where the font disappears in both GL and non-GL modes. Below, I provide a sample project and a video demonstrating the problem.

skiaerror.mp4

appSkiaSharpTest.zip

Steps to reproduce:

Use the x86 profile.
Then switch to Any CPU or x64 – the issue occurs only with the x86 profile.

Description:
When moving the cursor, I refresh the Skia control and paint using the following code:

    private void SK_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e)
    {
        var c = e.Surface.Canvas;
        using (SKPaint p = new SKPaint())
        {
            p.Color = SKColors.Red;
            e.Surface.Canvas.DrawRect(10, 10, 400, 400, p);
            p.Color = SKColors.Black;
            e.Surface.Canvas.DrawText("Hallo from skia !", 100, 100, font, p);
            p.Color = SKColors.Yellow.WithAlpha(128);
            e.Surface.Canvas.DrawRect(x - 10, y - 10, 200, 20, p);
        }
    }

Issue:
After a few invalidations, the text is no longer drawn correctly.

@maiad maiad changed the title [BUG] x86 fonts are corruptet [BUG] x86 fonts are corrupted Jan 4, 2025
@TAlecksen
Copy link

I am encountering this same issue when using Mapsui targeting SkiaSharp 3.116.0 or greater. When targeting the x86 platform, all text within the map moves to the top of the control.

@pauldendulk
Copy link

pauldendulk commented Feb 10, 2025

We have the same problem building an app with Mapsui.Wpf 5.0.0-beta.7. The bug only shows using x86 and only on two of three machines. So, not a very visible problem. But since we release to many users that are on x86 this is a blocking issue for us.

This is how the app starts:

Image

This is what happens after panning for five seconds:

Image

@mattleibow If you have any pointers on where to look in the source code I could try to investigate it.

@pauldendulk
Copy link

I did some more research.

  • I used the WinForms sample provided above by @maiad (thanks!) and could reproduce the problem in debug mode on my machine. This was not possible with other samples I received before (that did fail on other peoples machines).
  • I cloned SkiaSharp and added the WinForms sample, but as soon as I replaced the nuget package with project references it behaved correctly.
  • So, perhaps it was already fixed in main. I tried all kinds of stuff using the nightly build and copying libSkiaSharp around but the conclusion was that the bug was still in main.
  • I ran the WinForms sample in release mode and then it did reproduce! So, I was on the right track.
  • Stepping through the code showed that the DrawText method is using the obsolete SKPaint.TextAlign, when I replaced this with SKTextAlign left this solved the problem in release mode.

So, it seems this DrawText (and another one using SKPaint.TextAlign) should be made obsolete just like two other DrawText methods. There is a suppression of the warning, which suggests it was not made obsolete for a reason. Whichever is the case, for the SkiaSharp users perspective the solution is to use another overload.

This what I changed in the WinForms sample code:

// Don't use this:								
// e.Surface.Canvas.DrawText("Hallo from skia !", 100, 100, font, p);
// Use this instead:
e.Surface.Canvas.DrawText("Hallo from skia !", 100, 120, SKTextAlign.Left, font, p);

pauldendulk added a commit to pauldendulk/SkiaSharp that referenced this issue Feb 14, 2025
@pauldendulk pauldendulk linked a pull request Feb 14, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: New
Development

Successfully merging a pull request may close this issue.

4 participants