Skiasharp: [BUG] SKGLView UWP. PaintSurface event fires with the old size after window resize.

Created on 3 Jul 2020  路  2Comments  路  Source: mono/SkiaSharp

Description

PaintSurface event fires with old size after window maximizing/restoring.
On version 1.60 this event fires twice: with the old and new size. But after upgrade to 1.68.X only on褋e, with old size only.

Code

Xamarin Forms app for UWP

using SkiaSharp.Views.Forms;
using Xamarin.Forms;

namespace App3
{
    public class MainPage : ContentPage
    {
        public MainPage()
        {
            var SKGLView = new SKGLView();
            SKGLView.PaintSurface += SKGLView_PaintSurface;
            Content = SKGLView;
        }

        private void SKGLView_PaintSurface(object sender, SKPaintGLSurfaceEventArgs e)
        {
        }
    }
}

Expected Behavior

Event fires twice with the old and new size. Or on褋e with the new size.

Actual Behavior

Event fires with the old size.

Basic Information

  • Version with issue: v1.68.X
  • Last known good version: v.1.60.X
  • IDE: Visual Studio
  • Platform Target Frameworks:

    • UWP: 16299

backend-OpenGL os-Windows-Universal-UWP type-bug

Most helpful comment

Thanks @vpapenko for reporting this and thanks @daltonks for the workaround.

This is a weird thing. Looking at the code, I am listening to the size event in the underlying UWP control. And I am requesting a redraw there too.
https://github.com/mono/SkiaSharp/blob/master/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs#L158-L179

However, it looks that when the view changes, triggers a redraw, the underlying GL surface has not yet been recreated yet, so it is the old size. I think forms runs a little later, so it has had time to recreate the GL surface.

I'll have a look and see if there is some other event that needs to be subscribed to in order to get notified when the actual GL surface changes.

All 2 comments

I came across the same issue and found a workaround. You can listen for SKGLView.SizeChanged and InvalidateSurface whenever it's fired (this works for 2.80 at least, maybe it will for 1.68 as well).

Thanks @vpapenko for reporting this and thanks @daltonks for the workaround.

This is a weird thing. Looking at the code, I am listening to the size event in the underlying UWP control. And I am requesting a redraw there too.
https://github.com/mono/SkiaSharp/blob/master/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs#L158-L179

However, it looks that when the view changes, triggers a redraw, the underlying GL surface has not yet been recreated yet, so it is the old size. I think forms runs a little later, so it has had time to recreate the GL surface.

I'll have a look and see if there is some other event that needs to be subscribed to in order to get notified when the actual GL surface changes.

Was this page helpful?
0 / 5 - 0 ratings