locked
BingMap.SetView() causes error and crash the app now and then RRS feed

  • Question

  • Im using the bing map in my windows store app for updating my position every time the user moves. So every time the there is a new position, i use the function SetView() to center the map to the new position. Unfortunately, every time after about 20 min of following the position (and always call SetView()) the whole app crashs with an access violation exception in Windows.UI.Xaml.dll. (taken from the dump file).

    The crash only happens when i call SetView or when i set the center of the map manually with Map.Center = position.I dont think this is a known bug, because i dont find anything similar in the internet but i have no idea why this occurs.

    My xaml code:

     <Grid x:Name="mapGrid" Grid.ColumnSpan="2">
                    <Border Background="{Binding Source={StaticResource DesignViewModel}, Path=DesignModel.PageBackgroundBrush}">
                        <Maps:Map  x:Name="TargetsMap" Credentials="{StaticResource BingMapsApiKey}" ShowNavigationBar="True" ShowScaleBar="True">
                            <Maps:Map.Children>
                                
                                <!-- Data Layer-->
                                <Maps:MapLayer Name="DataLayer" />
     
                                <Maps:MapLayer>
                                    <Grid x:Name="Infobox" Visibility="Collapsed" Margin="0,-155,-10,0" Canvas.ZIndex="1">
                                        <Border Width="300" Height="155" Background="Black" Opacity="0.8" BorderBrush="White" BorderThickness="2" CornerRadius="5" />
                                        <StackPanel Height="145" Margin="5">
                                            <Grid Height="50">
                                                <TextBlock Text="{Binding Title}" Style="{StaticResource UniverseBold}" FontSize="20" Width="250" TextWrapping="Wrap" HorizontalAlignment="Left" />
                                                <Button Content="X" Tapped="CloseInfobox_Tapped" HorizontalAlignment="Right" VerticalAlignment="Top" />
                                            </Grid>
                                            <StackPanel>
                                                <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Height="40" HorizontalAlignment="Left">
                                                    <TextBlock Text="{Binding Description}" Style="{StaticResource UniverseLight}" FontSize="16" Width="290" TextWrapping="Wrap" Height="Auto" />
                                                </ScrollViewer>
                                                <Grid>
                                                    <Button x:Uid="DetailsButton" Style="{StaticResource UniversLightButton}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Tapped="Details_Tapped" Visibility="{Binding DetailsButton, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                                    <Button x:Name="btnSingleRoute" Style="{StaticResource UniversLightButton}" x:Uid="RouteButton" HorizontalAlignment="Right" VerticalAlignment="Bottom" Tapped="Tour_Tapped" Visibility="{Binding TourButton, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                                </Grid>
                                            </StackPanel>
                                        </StackPanel>
                                    </Grid>
                                </Maps:MapLayer>
                            </Maps:Map.Children>
                        </Maps:Map>
                    </Border>
                </Grid>
    My code to update the position on the map:
            private async void UpdateMyPosition(Geocoordinate coordinates, bool setView)
            {
                try
                {
                    await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        if (myPositionPushpin != null)
                            this.DataLayer.Children.Remove(myPositionPushpin);
    
                        myPositionPushpin = new Pushpin() { Template = MyPositionTemplate };
    
                        var position = coordinates.Location;
    
                        MapLayer.SetPosition(myPositionPushpin, position);
    
                        this.DataLayer.Children.Add(myPositionPushpin);
    
                        if (setView)
                           this.Map.SetView(position); // Here happens the crash i think. when i comment out this line, the crash not occur
                    });
                }
                catch (Exception exc) { Log.WriteLog(exc.ToString()); }
            }
    

    <UserControl x:Class="MyPositionMapPushpin" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Planzer.Apollo.TelematikApp" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <UserControl.Resources> <Storyboard x:Name="myPosStoryboard"> <ColorAnimation EnableDependentAnimation="true" Storyboard.TargetName="myPosEllipse" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" Duration="0:0:0.5" To="White" RepeatBehavior="Forever" AutoReverse="True"> </ColorAnimation> </Storyboard> </UserControl.Resources> <Canvas> <Border BorderBrush="Black" BorderThickness="2" CornerRadius="20" Width="16" Height="16" Canvas.Left="-8" Canvas.Top="-8"> <Ellipse x:Name="myPosEllipse" Fill="Blue" Loaded="myPosEllipse_Loaded"></Ellipse> </Border> </Canvas> </UserControl>

    This is the user-control of the pushpin of the current position. (--> MyPositionTemplate)

    Is there something wrong with the code? Somebody have a hint why such an exception can occure?

    If somebody could help, i really appreciate because i struggle with this bug quite a long time now.

    Thanks in advance.

    Tuesday, February 25, 2014 8:56 AM

Answers

  • Looks like i found the solution. It was the coloranimation in the UserControl from the map-pushpin:

     <Storyboard x:Name="myPosStoryboard">
                <ColorAnimation
                    EnableDependentAnimation="true"
                    Storyboard.TargetName="myPosEllipse"
                    Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)"
                    Duration="0:0:0.5" To="White"
                    RepeatBehavior="Forever" AutoReverse="True">
                </ColorAnimation>
            </Storyboard>

    i commented this out and the error did not occure again.the animiation was somehow not compatible with the zoom of the Map. Looks like a graphical Bug.

    Friday, February 28, 2014 12:29 PM

All replies

  • Is the catch statement being called when the error occurs? If not then try putting a try/catch inside the dispatcher. I haven't heard of anyone having this issue. IF you are able to catch the exception then try and get the stack trace information.


    http://rbrundritt.wordpress.com

    Tuesday, February 25, 2014 11:00 AM
  • Thanks for reply. No the catch is not being called, but i didnt try to put it in the dispatcher. i will do so and will update this post then.

    The only thing i have now is the callstack from a dump file which was generated by windows after the error occures (the dump file is not generated always when the error occurs for some reason):

    Windows.UI.Xaml.dll!SolidColorBrushClone::SetValue() Unknown Windows.UI.Xaml.dll!CDependencyObject::UpdateEffectiveValue() Unknown Windows.UI.Xaml.dll!CAnimation::DoAnimationValueOperation() Unknown Windows.UI.Xaml.dll!CAnimation::UpdateAnimation() Unknown Windows.UI.Xaml.dll!CTimeline::ComputeStateImpl() Unknown Windows.UI.Xaml.dll!CTimeline::ComputeState() Unknown Windows.UI.Xaml.dll!CStoryboard::ComputeStateImpl() Unknown Windows.UI.Xaml.dll!CHardwareCompositor::TickIndependentAnimations() Unknown Windows.UI.Xaml.dll!CompositorScheduler::RenderThreadFrame() Unknown Windows.UI.Xaml.dll!CompositorScheduler::RenderThreadMain(void) Unknown Windows.UI.Xaml.dll!CompositorScheduler::RenderThreadMainStatic(unsigned char *) Unknown kernel32.dll!@BaseThreadInitThunk@12() Unknown ntdll.dll!_RtlUserThreadStart() Unknown ntdll.dll!_RtlUserThreadStart@8() Unknown`

    Seems like a thread problem. But anyway, if i not bring it away i will redesign the whole code to see if it happens too.

    Thanks

    Tuesday, February 25, 2014 12:26 PM
  • Looks like i found the solution. It was the coloranimation in the UserControl from the map-pushpin:

     <Storyboard x:Name="myPosStoryboard">
                <ColorAnimation
                    EnableDependentAnimation="true"
                    Storyboard.TargetName="myPosEllipse"
                    Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)"
                    Duration="0:0:0.5" To="White"
                    RepeatBehavior="Forever" AutoReverse="True">
                </ColorAnimation>
            </Storyboard>

    i commented this out and the error did not occure again.the animiation was somehow not compatible with the zoom of the Map. Looks like a graphical Bug.

    Friday, February 28, 2014 12:29 PM