Using UseAcceleratedDisplay crashes my application

2712
2
04-09-2013 12:08 AM
Labels (1)
ArielLomes
New Contributor III
Hello.

I'm trying to use the UseAcceleratedDisplay property and no matter in what form I use it (either as a property in the esri:Map object or as an object on it's on by puting my layers in <AcceleratedDisplayLayers></AcceleratedDisplayLayers>) it crashes my application.

Here is an example of my XAML code:

<esri:Map x:Name="MyMap" esri:Editor.SnapDistance="0" WrapAround="True" Margin="1,1,1,0"  Height="{Binding Path=LocalSubLayerList}"
                      Background="White" MinimumResolution="0.001" MaximumResolution="1000" Style="{StaticResource MyMapStyle}"
                      MouseEnter="Map_MouseEnter" MouseLeave="Map_MouseLeave" MouseClick="QueryPoint_MouseClick" IsEnabled="False" IsLogoVisible="False" AllowDrop="True"
 UseAcceleratedDisplay="True">
                <esri:Map.Layers>
                    
                    <esri:LayerCollection>

                            <esri:ArcGISLocalDynamicMapServiceLayer ID="Layers" x:Name="MXD1" DisableClientCaching="True" EnableDynamicLayers="True"
                                                                Initialized="ArcGISLocalDynamicMapServiceLayer_Initialized"/>


                        
                            <esri:GraphicsLayer ID="SelectGraphic" RendererTakesPrecedence="True" ShowLegend="False"/>
                            <esri:GraphicsLayer ID="AreaGraphic" RendererTakesPrecedence="True" ShowLegend="False"/>
                            <esri:GraphicsLayer ID="DistanceGraphic" RendererTakesPrecedence="True" ShowLegend="False"/>


                    </esri:LayerCollection>
                    
                </esri:Map.Layers>
                
            </esri:Map>


A note: in the MPK I use, I load both my layers and my rasters, meaning I don't use TPK for loading my rasters. The reason for this is that when I used TPK and MPK seperately, for some reason the GraphicLayers didn't appear in the application.

Any ideas?
0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

Does your machine meet the minimum requirements for the hardware accelerated display?: DirectX 9 support, Shader model 2.0 or greater and at least 256MB dedicated graphics memory.

In the scenario where the display fails we raise an exception: Error: Failed to create Accelerated Display. Please check the display hardware and drivers meet the minimum requirements.

However - when you enable the accelerated display on the Map in XAML and the display creation fails then it happens early on and isn't caught by any of our event handlers. Therefore you should register a handler for the Application.Current.DispatcherUnhandledException. In the example below I've added the handler in the window class but you probably want to register this handler and handle the event in the Application class.

e.g.

public MainWindow()
{
    // License setting and ArcGIS Runtime initialization is done in Application.xaml.cs.

    Application.Current.DispatcherUnhandledException += AppDispatcherUnhandledException;

    InitializeComponent();
}

void AppDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
    // Process unhandled exception
    // If it's display-related the error message is: 
    // "Failed to create Accelerated Display. Please check the display hardware and drivers meet the minimum requirements."
    MessageBox.Show(e.Exception.Message);

    // Prevent default unhandled exception processing
    e.Handled = true;
    this.Close();
}


I appreciate this is not sufficiently documented - I'll investigate that and we'll also consider how better we can handle this for you as the developer.

Cheers

Mike
0 Kudos
BKuiper
Occasional Contributor III
We use the following code to determine if the hardware requirements are sufficient on the machine of the user

                    int tier = (System.Windows.Media.RenderCapability.Tier >> 16);

your fine when tier > 1, otherwise you will need to run without AcceleratedDisplay

Hi,

Does your machine meet the minimum requirements for the hardware accelerated display?: DirectX 9 support, Shader model 2.0 or greater and at least 256MB dedicated graphics memory.

In the scenario where the display fails we raise an exception: Error: Failed to create Accelerated Display. Please check the display hardware and drivers meet the minimum requirements.

However - when you enable the accelerated display on the Map in XAML and the display creation fails then it happens early on and isn't caught by any of our event handlers. Therefore you should register a handler for the Application.Current.DispatcherUnhandledException. In the example below I've added the handler in the window class but you probably want to register this handler and handle the event in the Application class.

e.g.

public MainWindow()
{
    // License setting and ArcGIS Runtime initialization is done in Application.xaml.cs.

    Application.Current.DispatcherUnhandledException += AppDispatcherUnhandledException;

    InitializeComponent();
}

void AppDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
    // Process unhandled exception
    // If it's display-related the error message is: 
    // "Failed to create Accelerated Display. Please check the display hardware and drivers meet the minimum requirements."
    MessageBox.Show(e.Exception.Message);

    // Prevent default unhandled exception processing
    e.Handled = true;
    this.Close();
}


I appreciate this is not sufficiently documented - I'll investigate that and we'll also consider how better we can handle this for you as the developer.

Cheers

Mike
0 Kudos