WPF Animations On Slow Systems
There is always the demand that the new fancy application with all the animations has to do exactly the same job on slow office machines as on high end gaming engines. There are serveral ideas and recommodations to reach that goal. But most of them will lead only to failure. And that is why.
Usually animations are measured in Frames. Let us start with a simple example (the following is harshly exaggerated but based on a real case with a complex animation. But for just making the point it is sufficient).The ball has to reach the wall dropping two times on the ground before. The Animation is shown in 15 Frames.
.
| O |
|
|
|
O |
O |
|
|
|
O |
O |
|
|
|
O |
|
| |
O |
|
O |
|
|
O |
|
O |
|
|
O |
|
O |
|
|
| |
|
O |
|
|
|
|
O |
|
|
|
|
O |
|
|
|
| 1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
|
.
In a system capable of showing 10 frames per seconds the animation will be done in 1,5 seconds. A gaming system with 30 frames per seconds will be finished one second earlier. That is not what we want. After all the sound team developed a superb soundfile for two plopps and one bang with an exact duration of one second. So we use DoubleAnimation for our bouncing ball setting a duration and start again. And to no surprise it works in time. But alas the animation is looking awful like a robotic pacman on the gaming system and looks like that on the slow office system:
| O |
|
|
|
O |
|
|
|
|
O |
|
|
|
|
O |
|
| |
|
O |
|
|
|
O |
|
O |
|
|
O |
|
O |
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
|
| t = 1 second |
|
.
So our next try is DoubleAnimationUsingKeyFrames and we are using SplineDoubleKeyFrames to make the ball bounce more realistic. Now it really looks cool on the gaming system, synchronous to the soundfile and everybody seems to be happy. But as old Murphy told us, something always goes wrong. In this case it is the old office system or the NVIDIA driver on the presentation Laptop. The ball does not bounce at all, it jumps. .
| O |
|
|
|
O |
|
|
|
|
O |
|
|
|
|
O |
|
| |
|
|
|
|
O |
|
|
|
|
|
O |
|
|
|
|
| |
|
O |
|
|
|
|
O |
|
|
|
|
O |
|
|
|
| 1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
|
| t = 1 second |
|
.
Beside the fact, that this simple animation eats up 25 percent of CPU power, it still looks awful. And what do we learn? You cannot produce nice looking time-based animations on an old office system with WPF? Sadly that is true. There are some ways to work around that problem, using CompositionTarget.Rendering or develop a own animation class and manipulate the value based on timespans. But there is no way to create a clean and nice looking animation with standard classes for slow systems. You can always rely on the old Flash bag of tricks (e.g. using two animations based on clock controlled value changes with a second animation as a washed shadow of the moving ball). But like Iron Maiden singer Bruce Dickinson once stated: "Oh no sorry, you can't play heavy metal with a synthesizer."
As I said, this is highly exaggerated, and nobody should be afraid of bouncing a ball with WPF on any computer system capable of carrying Vista. But when it comes to complex 3D animations, stop the marketing department from spreading promises nobody can keep.
p.s.
Few years later since the album Somewhere In Time (1986) Iron Maiden started to use synthesizers.