WPF Choppy Animation
Posted
by Chris Dunaway
on Stack Overflow
See other posts from Stack Overflow
or by Chris Dunaway
Published on 2010-06-03T20:56:32Z
Indexed on
2010/06/10
5:22 UTC
Read the original article
Hit count: 489
WPF Windows-XP SP3
I'm having a problem with a simple WPF animation.
I use the following Xaml code (in XamlPad and also in a WPF project):
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Border Name="MyBorder" BorderThickness="10" BorderBrush="Blue" CornerRadius="10" Background="DarkRed" >
<Rectangle Name="MyRectangle" Margin="10" StrokeDashArray="2.0,1.0" StrokeThickness="10" RadiusX="10" RadiusY="10" Stroke="Black" StrokeDashOffset="0">
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Rectangle.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="MyRectangle" Storyboard.TargetProperty="StrokeDashOffset" From="0.0" To="3.0" Duration="0:0:1" RepeatBehavior="Forever" Timeline.DesiredFrameRate="30" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</Border>
</Page>
It has the effect of causing the border to animate around the rectangle. After a fresh reboot of the machine, this animation is nice and smooth. However, I tend to leave my machine on all the time and after a period time elapses (I don't know how long), the animation starts stuttering and becomes choppy.
I thought that it may be memory or resource issues, but after shutting down all other apps and any services that seem unnecessary, the stuttering still continues. However, after a system reboot, the animation is smooth again!
I get the same symptoms in a WPF app or in XamlPad. In the case of the app, it doesn't seem to make any difference whether I run in the debugger or if I run the executable directly.
I applied the patch at this link: http://support.microsoft.com/kb/981741 and I thought that it had taken care of the issue, but it seems not to have.
I have seen some posts that might indicate that using transparency might affect animation, but as you can see, my xaml does not use transparency.
Can anyone give me some suggestions on how to determine what the problem is? Are there any WPF diagnostic tools that might help?
UPDATE: I have checked my video drivers and they are the latest version. (nVidia GeForce 8400 GS)
© Stack Overflow or respective owner