uno: Button does not revert back from a pressed state

Current behavior

When multiple buttons are on screen and the user makes several quick selections, buttons can be stuck in a pressed state. This could be a pointer issue but I do not know for certain.

This behavior appears most often with a GTK build (linux arm64), utilizing touch only, and while under heavy CPU usage. Note that I using software rendering as OpenGLES is not support with my current GPU.

Expected behavior

Button should revert back to the normal (unpressed state).

How to reproduce it (as minimally and precisely as possible)

Using Uno Material Win UI 2.3.0

The following page and styles were used in the provided gif and screen shots below.

Run the page below. Make multiple quick selections to buttons on screen. Eventually one will get stuck on a focused state.

<Page
    x:Class="App1.ButtonStateStuckPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:App1"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    mc:Ignorable="d">
    <Page.Resources>
        <Style x:Key="FeedbackButton" TargetType="Button">
            <Setter Property="Padding" Value="0" />
            <Setter Property="Margin" Value="4" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="CornerRadius" Value="10" />
            <Setter Property="Template">
                <ControlTemplate TargetType="Button">
                    <!--<Grid x:Name="MainGrid">-->
                    <ContentPresenter
                        x:Name="ContentPresenter"
                        Padding="{TemplateBinding Padding}"
                        HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalAlignment}"
                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Content="{TemplateBinding Content}"
                        ContentTemplate="{TemplateBinding ContentTemplate}"
                        CornerRadius="{TemplateBinding CornerRadius}" />
                    <!--</Grid>-->

                    <!--<VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal">
                            <Storyboard>
                                <PointerUpThemeAnimation Storyboard.TargetName="MainGrid" />
                            </Storyboard>
                        </VisualState>

                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainGrid" Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="White" />
                                </ObjectAnimationUsingKeyFrames>

                                <PointerDownThemeAnimation Storyboard.TargetName="MainGrid" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>-->

                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal" />

                            <VisualState x:Name="Pressed">
                                <VisualState.Setters>
                                    <Setter Target="ContentPresenter.BorderBrush" Value="White" />
                                </VisualState.Setters>
                            </VisualState>

                            <VisualState x:Name="PointerOver">

                                <VisualState.Setters />
                            </VisualState>
                        </VisualStateGroup>

                        <VisualStateGroup x:Name="FocusStates">

                            <VisualState x:Name="Focused" />

                            <VisualState x:Name="PointerFocused" />

                            <VisualState x:Name="Unfocused" />
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                </ControlTemplate>
            </Setter>
        </Style>
    </Page.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="100" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="100" />
            <RowDefinition Height="100" />
            <RowDefinition Height="100" />
            <RowDefinition Height="100" />
        </Grid.RowDefinitions>

        <Button Style="{StaticResource FeedbackButton}">
            <TextBlock Text="1" />
        </Button>

        <Button Grid.Column="1"  Style="{StaticResource FeedbackButton}">
            <TextBlock Text="2" />
        </Button>

        <Button Grid.Column="2"  Style="{StaticResource FeedbackButton}">
            <TextBlock Text="3" />
        </Button>

        <Button Grid.Column="3"  Style="{StaticResource FeedbackButton}">
            <TextBlock Text="4" />
        </Button>

        <Button Grid.Column="4"  Style="{StaticResource FeedbackButton}">
            <TextBlock Text="5" />
        </Button>

        <Button Grid.Row="1" Style="{StaticResource FeedbackButton}">
            <TextBlock Text="5" />
        </Button>

        <Button Grid.Row="1" Grid.Column="1"  Style="{StaticResource FeedbackButton}">
            <TextBlock Text="6" />
        </Button>

        <Button Grid.Row="1" Grid.Column="2"  Style="{StaticResource FeedbackButton}">
            <TextBlock Text="7" />
        </Button>

        <Button Grid.Row="1" Grid.Column="3"  Style="{StaticResource FeedbackButton}">
            <TextBlock Text="8" />
        </Button>

        <Button Grid.Row="1" Grid.Column="4"  Style="{StaticResource FeedbackButton}">
            <TextBlock Text="9" />
        </Button>
    </Grid>
</Page>

Environment

Windows Linux GTK

Nuget Package: Uno Material Win UI

Package Version(s): 2.3.0

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renders for Xamarin.Forms
  • Windows
  • Linux
  • Build tasks

Visual Studio:

  • 2017 (version: )
  • 2019 (version: )
  • for Mac (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

button-linux-arm64 button-vid

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 30 (13 by maintainers)

Most upvoted comments

Unfortunately no I’m not able to find any relevant log that would dump the element name. However you have something like “TextBlock-00F3E9B8” the “00F3E9B8” is .GetHashCode().ToString("X8"), so you can dump in your page init the hashcode with the name o we can match.

Unfortunately looking at your logs, I realized that they are not making any sense, and indeed: #11771 😕 So please could send us new logs with packages updated? (once this PR has been merged and package published.)

Another option, if you are willing to, would be to re-compile uno with this line un-commented

https://github.com/unoplatform/uno/blob/927a09f70d90f6fb1c9f03a3b77f5577d57240fe/src/Uno.UI/UI/Xaml/UIElement.RoutedEvents.cs#L1

and use it in your app (cf. Debugging Uno in another application) … it will dump AT LOT of logs (with control names).

I’ll see if I can compile the source but it may be some time before I can get to it. I will definitely update to the latest once you have merged #11771

@brswan Did you have a chance to validate this has been fixed please?

I haven’t seen this happen with the latest release. I’m good with closing this. Thanks for your assistance.

You can use 4.9.0-dev.834, or any later build.