Double Buffering in Android using SKGLView seems to not be working?

The attached solution is the minimum to reproduce a problem I am having with Android.

The app draws two white "cards" (of course, more complex in the real app). There is a border between them and basic touch control to swipe left and right between them. I have added a 20ms delay to simulate a long draw time.

In IOS and UWP, the result is two white boxes with a clear blue line between them. The blue line is always the same size.

In Android, the result is two white boxes but the blue line changes in size depending on the speed of the swipe.

The boxes are drawn within the same OnPaintSurface call, so should never be different sizes unless the canvas is being rendered **during **the call. Does this mean that double buffering is not working?

I haven't tried rendering to a bitmap yet because I wanted to check if it is a bug that can be fixed.

BTW, the attached solution is a completely fresh "New Project" and the only additions are the CardView.cs and "Content = new CardView();" in the MainPage constructor in the common library and the reference to the SkiaSharp nugets added as needed.

Finally, this arises from tests on hardware and the android device is the most modern - flagship level from a year ago so there should be no issues with hardware capability.

Best Answer

  • NickWhitehurstNickWhitehurst GB ✭✭
    edited December 2018 Accepted Answer

    Actually, yes I have just stumbled upon it as I was writing a reply.

    The OnTouch method is called while the OnPaintSurface method is running so the animation position was being modified. I have confirmed this doesn't happen with UWP, but not yet with IOS.

    So lessons is, don't assume touch and paint calls will not overlap.

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    What have you tried? And have you got the solution?

  • NickWhitehurstNickWhitehurst GBMember ✭✭
    edited December 2018 Accepted Answer

    Actually, yes I have just stumbled upon it as I was writing a reply.

    The OnTouch method is called while the OnPaintSurface method is running so the animation position was being modified. I have confirmed this doesn't happen with UWP, but not yet with IOS.

    So lessons is, don't assume touch and paint calls will not overlap.

Sign In or Register to comment.