SKGLView + Android is a Child of a Grid, Background of Grid goes black

DavidLedgerDavidLedger AUMember ✭✭

Hello,

Where
I have a grid with a few buttons and a SKGLView.

When
When any of the children of the grid are hidden the background colour of the Grid goes black
(Until invalidate layout is called).
Manually calling the InvalidateLayout() layout function immediately after restoring the child element doesn't resolve the issue, regardless of the thread that invalidate is called from.

This is only with android and only with SKGLView, it doesn't happen with SKCanvasView.

Unacceptable Fix
The following does solve the problem but isn't practical:
After the layout has changed allow the user to press a button that calls InvalidateLayout(). This immediately resolves the background colour issue.

I believe this works because it is called well after all of the paint calls are made.

Unacceptable workaround
SKCanvasView functions correctly however cannot be used for various reasons.

Answers

  • DavidLedgerDavidLedger AUMember ✭✭
    edited November 2017

    Update
    A timer set for 1 second which runs in background then executes the invalidate layout on the main thread doesn't work, but again pressing a button does.
    Pressing a button to invalidate layout isn't really an workable solution.

  • DavidLedgerDavidLedger AUMember ✭✭
    edited November 2017

    Update
    This is a dumb work around, its really dumb so be warned...
    Really really dumb, like just ... not a stable solution either as it depends on whether the layout and redraw is complete. Slow phones may fail lol.

    After changing visibility triggering the following:

            async private void DelayedStupidFunction()
            {
            //50 is too short, this is way too much delay....
                await Task.Delay(200);
                Globals.RunMainThread(() => {
                    Children[0].IsVisible = false;
                    Children[0].IsVisible = true;
                });
            }
    

    Not really an acceptable solution either but might indicate to someone a better work around.

    Update
    Less crazy but still horrible.

            async private void DelayedStupidFunction()
            {
                await Task.Delay(100);
                Globals.RunMainThread(() => {
                    var count = Children.Count;
                    if (count > 0)
                    {
                        Children[count - 1].IsVisible = false;
                        Children[count - 1].IsVisible = true;
                    }
                });
            }
    
  • jamessmith.2438jamessmith.2438 USMember ✭✭
    edited November 2017

    i also met some similar problem with android 6.0 XiaoMi 4
    where background is entirely black

  • mattleibowmattleibow ZAXamarin Team Xamurai

    It might be related to this: https://github.com/mono/SkiaSharp/issues/263

    The fix will be to use a TextureView - but this is not yet implemented.

  • DavidLedgerDavidLedger AUMember ✭✭

    Thanks! Do you have a timeframe on the textureview?

Sign In or Register to comment.