Android ScrollViewer Error!

Hi I having a error with this code in many Android device! I use Fuse (beta) v0.1.2658 and I reproduce the error in this code:

<App Theme="Basic" ux:Class="MyApp" ClearColor="0.9,0.9,0.9,1">
    <DockPanel>

        <Panel WidthUnit="Percent" Width="100" HeightUnit="Percent" Height="100" >
            <ScrollViewer WidthUnit="Percent" Width="100" HeightUnit="Percent" Height="70" Background="Red" Alignment="Bottom">
                <StackPanel Orientation="Vertical">
                    <Rectangle WidthUnit="Percent" Width="100" Height="100" Margin="10">
                        <SolidColor Color="#333" />
                    </Rectangle>
                    <Rectangle WidthUnit="Percent" Width="100" Height="100" Margin="10">
                        <SolidColor Color="#333" />
                    </Rectangle>
                    <Rectangle WidthUnit="Percent" Width="100" Height="100" Margin="10">
                        <SolidColor Color="#333" />
                    </Rectangle>
                    <Rectangle WidthUnit="Percent" Width="100" Height="100" Margin="10">
                        <SolidColor Color="#333" />
                    </Rectangle>
                    <Rectangle WidthUnit="Percent" Width="100" Height="100" Margin="10">
                        <SolidColor Color="#333" />
                    </Rectangle>
                    <Rectangle WidthUnit="Percent" Width="100" Height="100" Margin="10">
                        <SolidColor Color="#333" />
                    </Rectangle>
                    <Rectangle WidthUnit="Percent" Width="100" Height="100" Margin="10">
                        <SolidColor Color="#333" />
                    </Rectangle>
                </StackPanel>
            </ScrollViewer>
        </Panel>
        <Page>
        <Panel WidthUnit="Percent" Width="100" Height="100" HeightUnit="Percent" Alignment="Top" />
        </Page>

    </DockPanel>
</App>

When I open the app I see this and all work fine:

Then I put the app in background like this:

And when I open again the app the scrollViewer dont respect his height! The ScrollViewer height must be 70% but when I open again is in 100% and blick all the time!

Also when I do the same process other things works bad, like animations…

Thanks!

Thanks for reporting.

This looks like the GL state leak problem with apps going into background and resurrecting.

We are aware of this problem and working on a solution :slight_smile:

Yeah, this is an OpenGL ES state leakage, that happens when going to the background. It was fixed yesterday, but unfortunately that was not in time for the release that is right around the corner. So the fix won’t be released just yet.

However, for now, you can work around it with a bit of code-behind, like so:

public partial class MyApp
{
    public MyApp()
    {
        InitializeUX();

        // Work around a bug in the Fuse libraries (TODO: remove)
        if (defined(Android))
            Uno.Platform2.Application.EnteringForeground += OnEnteringForeground;
    }

    void OnEnteringForeground(Uno.Platform2.ApplicationState appState)
    {
        // Unfortunately, our new OpenGL ES context is not yet ready,
        // we're still in a pbuffer-context from running in the backgruond.
        // So let's schedule a callback before rendering the next frame,
        // so we can repair the corrupt state.
        Fuse.UpdateManager.AddAction(OnFirstUpdateAfterForeground);
    }

    void OnFirstUpdateAfterForeground()
    {
        // Scissor enable is the only state that leaks, so let's
        // re-enable it before we start rendering again.
        OpenGL.GL.Enable(OpenGL.GLEnableCap.ScissorTest);
        Fuse.UpdateManager.RemoveAction(OnFirstUpdateAfterForeground);
    }
}

Thanks!!! :slight_smile: