views:

213

answers:

2

I am developing WPF application and client reports extreamly high CPU usage (90%) (whereas i am unable to repeat that behavior). I have traced bootleneck down to these lines. It is simple glowing animation for small single led control (blinking led). What could be reason for this simple annimation taking up SO huge CPU resources?

         <Trigger Property="State"> 
            <Trigger.Value> 
                <local:BlinkingLedStatus>Blinking</local:BlinkingLedStatus> 
            </Trigger.Value> 
            <Trigger.EnterActions> 
                <BeginStoryboard Name="beginStoryBoard"> 
                    <Storyboard> 
                        <DoubleAnimation Storyboard.TargetName="glow" Storyboard.TargetProperty="Opacity" AutoReverse="True" From="0.0" To="1.0" Duration="0:0:0.5" RepeatBehavior="Forever"/> 
                    </Storyboard> 
                </BeginStoryboard> 
            </Trigger.EnterActions> 
            <Trigger.ExitActions> 
                <StopStoryboard BeginStoryboardName="beginStoryBoard"/> 
            </Trigger.ExitActions> 
        </Trigger> 
+3  A: 

Chances are that your client does not have hardware accelleration. Todays (and even yesterdays) graphics cards should be sufficient to render WPF. Tell him to update his graphics drivers. You can also tune your animation a little bit by setting Timeline.DesiredFrameRate="20" (or lower if it suitable for you) on your StoryBoard.

bitbonk
I tried that, but usage got decreased only by little! The thing is, that this component is realy small (50x50 pixels). Evens with fps 30 he reported, that cpu usage still is 70%. That is icreadibly much for blinkig 50x50 square ... :/
0xDEAD BEEF
Did you check the GPU hardware (and its drivers)?
bitbonk
+2  A: 

WPF's animations and effects are computationally intensive. They require hardware acceleration to work smoothly. This means that is needs a decent graphics card to play nicely.

You can check whether your app can use hardware acceleration as described here, and remove the glow effect if it doesn't.
(Or just dumb it down, for example add a simple white rectangle instead of it, or something like that.)

I once wrote a simple application which extensively used all sorts of effects and animation, and it was barely usable on an average machine. I dumbed down the effects, and everything became smooth.

Venemo