The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
[UWP]Delay + FlipView + GridView Cause W10M Crash RRS feed

  • Question

  • I am developing a UWP app and seem to find a bug of Windows 10 Mobile (W10M).
    I created a minimal example to demo the bug in the following. The MainPage of the example app has a FlipView.

    <Page
        x:Class="FlipViewTest.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:FlipViewTest"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <FlipView ItemsSource="{x:Bind gvps, Mode=OneWay}">
            </FlipView>
        </Grid>
    </Page>

    In MainPage class, I used an async function init to build the ItemSources:

    public sealed partial class MainPage : Page
        {
            ObservableCollection<GridViewPage> gvps = new ObservableCollection<GridViewPage>();
            public MainPage()
            {
                this.InitializeComponent();
                init();
            }
    
            public async Task<int> init()
            {
                // Simulate some processing.
                await Task.Delay(1000);
    
                var strs = new ObservableCollection<string>();
                var strs2 = new ObservableCollection<string>();
                for (int i = 0; i < 20; i++)
                {
                    strs.Add("" + i);
                    strs2.Add("" + (i + 20));
                }
    
                var gvp = new GridViewPage(strs);
                var gvp2 = new GridViewPage(strs2);
                gvps.Add(gvp);
                gvps.Add(gvp2);
    
                return 0;
            }
        }

    Pay attention to the Task.Delay in init. I will talk about it later.

    The ItemsSource of the FlipView is a ObservableCollection of a page GridViewPage:

    <Page
        x:Class="FlipViewTest.GridViewPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:FlipViewTest"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <GridView x:FieldModifier="public" x:Name="gv" ItemsSource="{x:Bind strs, Mode=OneWay}">
            <GridView.ItemTemplate>
                <DataTemplate x:DataType="x:String">
                    <Border Background="Green" VerticalAlignment="Center" Height="100">
                        <TextBlock Text="{Binding}" Foreground="White" FontSize="22" Width="145" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
                    </Border>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>
    </Page>

    The GridViewPage class is:

        public sealed partial class GridViewPage : Page
        {
            ObservableCollection<string> strs = new ObservableCollection<string>();
            public GridViewPage(ObservableCollection<string> _strs)
            {
                this.InitializeComponent();
                foreach(var s in _strs)
                {
                    strs.Add(s);
                }
            }
        }
    The full code can be download here:

    https://github.com/MrMYHuang/FlipViewTest

    If you run this app on W10M phone (actually I have no W10M phone. I run it on W10M build 10586 emulator), you will see the FlipView has two slides. The problem is: if the app just start, you immediately swipe the first slide of the FlipView leftward to the second slide, and immediately swipe the second slide upward, then the app has a possibility of crash. If you remove the Task.Delay of init function, the problem disappear. However, in practice, there may be a processing time for some works before creating FlipView ItemsSource. So, in practice, some apps will suffer from this crash problem. Please Microsoft fix this bug. This bug seems to exist also in W10M build 14393.

     I recorded a video to demo the crash: https://1drv.ms/v/s!AidUO2jm9c6Hk_5GRRKW3uQCMcPPjg






    • Edited by Meng-Yuan Huang Thursday, December 22, 2016 2:41 AM
    • Edited by Jayden Gu Friday, December 23, 2016 6:46 AM title tag
    Thursday, December 22, 2016 2:20 AM

All replies

  • Hi Meng-Yuan Huang,

    I test it on the device of Lumia 640 that I can reproduce your issue. It can works on desktop. Also I try to set the different time for the Task.Delay method. When I set 20 to it, it works.

    I am working on this, if any update, I will post here.


    Best Regards,

    Jayden Gu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 23, 2016 9:27 AM