Archive for the ‘ Citrix ’ Category

Reduce frame rate for WPF animations to gain performance

 

Animations are very cool, but they can cause a high CPU load. One reason could be a missing hardware acceleration due to a old graphics adapter or a software rendering constraint. Another reason could be the the high frame rate of animations that is set to 60 fps by default.

You can easily lower the framerate for all animations by overriding the DesiredFrameRate property of the timeline. Just add the following code to your project and play around with the setting to find a good tradeoff between performance and aesthetic.

Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline),
   new FrameworkPropertyMetadata { DefaultValue = 30 });

Or you can set the framerate individually for each animation in XAML, using the following code:

<DoubleAnimation
    Storyboard.TargetProperty="Opacity"
    Duration="0:0:0.5" From="1.0" To="0.5"
    Timeline.DesiredFrameRate="30" />

In my current project we have a WPF application that is executed through Citrix. The frame rate has not been an issue until the application was run on a thin client/terminal with extremely limited resources and the application took 100% CPU when running the simplest animation. Our LOB WPF application does not have many animations but the once that are there are needed, so removing animations was out of the question. But we really don’t need 60 fps! So lowering frame rate to 15 made CPU performance go from 100% to 10% when animations was executed, and they all looked the same. Nice feature to know about!

Bypassing the Authenticode Signature Check on Startup

 

Authenticode verification will hurt startup time. I recently experienced this on a customer project. The initial startup time to show some parts of the UI took way to long first time accessing them. The WPF application is accessed through Citrix which also affects the startup performance for assemblies that needs to be verified.

Authenticode-signed assemblies need to be verified with the CA.  This verification can be time intensive, as it can require hitting the network several times to download up to date certificate revocation lists, and also to ensure that there is a full chain of valid certificates on the way to a trusted root.  This can, as in our case, end up in several seconds delay while that assembly is being loaded. Worst case for us was almost 30 sec for some client setups.

To get rid of this issue you can either install the CA certificate on the client machine or avoid using Authenticode when possible. We know that our application doesn’t need the Publisher evidence so we can do the following.

In .NET Framework 3.5 there is a configuration option that allows bypassing the Authenticode verification.  This can be done by adding adding the following lines to the .exe.config file:

<configuration>
        <runtime>
              <generatePublisherEvidence enabled="false"/>
       </runtime>
</configuration>

More information is available here as well as on this blog.

KB936707 discuss how you can also enable this in .NET Framework 2.0

%d bloggers like this: