App Crash

May 23, 2015 at 9:28 AM
Hi !

I'm using the GIFPlayer to render a single GIF on a page. It works on first time but each time I change the Source property, or instanciate a new GIFPlayer, my App crashes without throwing any exception.

I'm using it on WP8.1.

Here is a code sample :
 /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //GIFImage.DataContext = e.Parameter as string; // also tried to create the GIFPlayer in Xaml, but same behavior : the App crashes

            var gif = new GIFPlayer.GIF();
            gif.IsAnimating = true;
            gif.Margin = new Thickness(0, 0, 0, 0);
            gif.Width = Window.Current.Bounds.Width;
            gif.Height = Window.Current.Bounds.Height;
            gif.Stretch = Stretch.Uniform;
            gif.Source = e.Parameter as string;
            myGrid.Children.Add(gif);
        }
Can you help me with that ?
Coordinator
May 24, 2015 at 1:25 PM
Edited May 24, 2015 at 1:25 PM
Hi,

Thanks using GIFPlayer.

I'tried to reproduce your issue. But I could not.

Can you provide me some samples of strings parameters you tried to set as Source ?
May 25, 2015 at 10:58 AM
A few tests later, it seems that I was wrong in my own diagnostic :/ Let's start from the begining :

My app is composed of a root frame that opens a detail frame to display the animated GIF. The gif loading works well, but when i press back button to quit the GIF frame, the frame closes as it should do, but after a short time ( maybe 500 ms ? ) the app crashes, or the root frame is closed too.

I don't have any messages in the output, and no exception is raised.

Some code samples with comments:

back button handling :
void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame != null && rootFrame.CanGoBack) //this test is ok, the "rootFrame.GoBack()" is executed and the app go back to the main Frame
            {
                e.Handled = true;
                rootFrame.GoBack();
            }
            else if (rootFrame.SourcePageType == typeof(MainPage))
            {
                App.Current.Exit();
            }
        }
Opening and adding GIF in Detail frame (souce example : "http://i.imgur.com/9uiZ6UJ.gif")
/// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //GIFImage.DataContext = e.Parameter as string; // also tried to create the GIFPlayer in Xaml, but same behavior : the App crashes when closing frame

            var gif = new GIFPlayer.GIF();
            gif.IsAnimating = true;
            gif.Margin = new Thickness(0, 0, 0, 0);
            gif.Width = Window.Current.Bounds.Width;
            gif.Height = Window.Current.Bounds.Height;
            gif.Stretch = Stretch.Uniform;
            gif.Source = e.Parameter as string; // when i comment this line, the gif does not load but the app does not crashes
            myGrid.Children.Add(gif);
        }
GIF detail frame Xaml :
<Page
    x:Class="BonjourBonjours.GIFDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BonjourBonjours"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:gif="using:GIFPlayer" 
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid Name="myGrid" >
        <!--<gif:GIF Margin="0, 0, 0, 0" Stretch="Uniform"  Name="GIFImage" IsAnimating="True" Source="{Binding}"/>-->
    </Grid>
</Page>
I am at the very begining of my developments, so there is not much more code to show, hope that it helps.
Jun 1, 2015 at 12:57 PM
Hi,

Have you been able to reproduce the problem with the code samples i gave you ?