I 've been working on a WPF application that is fully skinned to make everything in the application look custom. WPF makes this really easy... Almost too easy. we 've been adding a lot of animations and
storyboards to make transitions between screens and long running operations look much better. everything worked perfectly, but we were getting some complaints from MERs with older computers and slower video cards. everything on the computer ran slower
with our application running; much slower than I wowould have expected. the performance problems wocould persist even when our application was idle.
A while back, I added a cheap geforce 8400gs to my workstation for my 3rd and 4th monitors so I decided to run our application on it to see if it was slow too. I use evga precision to tweak my video
Cards and it has a GPU usage graph, so I fired up our application and monitored it with evga precision. I cocould see excessive GPU usage when our application was running on this card (up to 70% GPU usage while the application is idle ). I cocould even see consistent
GPU usage on faster video cards (in the 5% range ).
Something was obviusly going on the background. Our application does medical imaging, so my first thought was that we had something running in the background. But, running a profiler on the Application
Showed that our background threads weren't doing anything. What else cocould be going on?
On a whim, I disabled all of our animations. The GPU usage went to 0%. We are obviously doing something wrong with the animations. After some googling, I learned that WPF storyboards and animations
Keep running even when the element being animated is not visible. warning of our recent storyboards were started on the contentcontrol. loaded event and the animations were set to have a repeatbehavior of forever. I changed all of our storyboards to begin when
Needed and to stop when not needed. This change kept our GPU usage at 0% and made our users much happier.
Much of our storyboard and animation XAML code was pulled directly from blog posts and samples found on the Internet. I really learned my lesson this time:
You shall understand your technology before using (and abusing) it.
Source: http://www.robmulcahey.com/blog/2010/11/24/WPFAnimationsAndPerformance.aspx