High CPU-usage when moving floating ToolWindow

Docking/MDI for WPF Forum

Posted 7 years ago by Farris
Version: 17.1.0651
Platform: .NET 4.6
Environment: Windows 10 (64-bit)
Avatar

Hello.

I've run into some performance issues. When moving a floating ToolWindow, the UI of the rest of my application seems to freeze. To pinpoint the issue, I used JetBrains dotTrace. 

The main "offenders" seems to be ActiproSoftware.Windows.Themes.WindowChromeShadow.Reposition(), called from OnPrimaryWindowLocationChanged

and

ActiproSoftware.Windows.Themes.WindowChromeManager.WindowProc(IntPtr, Int32, IntPtr, IntPtr, ref Boolean)

Here is some more info from the profiling:

6,40% OnPrimaryWindowLocationChanged • 7 077 ms • ActiproSoftware.Windows.Themes.WindowChromeShadow.OnPrimaryWindowLocationChanged(Object, EventArgs)
6,40% Reposition • 7 076 ms • ActiproSoftware.Windows.Themes.WindowChromeShadow.Reposition()
► 3,09% set_Top • 3 411 ms • System.Windows.Window.set_Top(Double)
► 2,87% set_Left • 3 174 ms • System.Windows.Window.set_Left(Double)
0,00% set_Left • 0,5 ms • System.Windows.Window.set_Left(Double)
0,00% get_VisibilityCache • 0,4 ms • System.Windows.UIElement.get_VisibilityCache()

and

2,16% WindowProc • 2 388 ms • ActiproSoftware.Windows.Themes.WindowChromeManager.WindowProc(IntPtr, Int32, IntPtr, IntPtr, ref Boolean)
► 2,11% #mAb • 2 331 ms • #Ci.#Bi.#mAb(#Dwg, Window, IntPtr, IntPtr)

 

Do you have any suggestions how I can prevent the UI from freezing while moving a window? Is there maybe a way to disable the drop shadow (if that is what's causing this issue)?

Thanks,

Farris

Comments (3)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Farris,

I'm sorry you're running into some performance issues.  I wouldn't expect the window move to cause any kind of freezing issues, and we haven't ever seen anything like that or had it reported.  Everything runs snappy for us.  Do you see this performance degradation in our sample app?

The WindowChromeShadow is the outer drop shadow effect.  It's basically just a transparent Window with shadow rendering that sits behind the main Window and moves with it.  Office apps do the same thing.  

The WindowChromeShadow.Reposition method just ensures the z-order is correct, updates the shadow Window's Left/Top/Width/Height to match, and sets its Clip property.  All of that should really be about instant.

As a test, you could switch to any non-Metro Actipro theme to see if that helps at all.  Only the Metro themes have that shadow.  Let us know what you find.


Actipro Software Support

Posted 7 years ago by Farris
Avatar

I had some issues trying to set a different theme in my application; the theme is only applied to docked windows. as soon as they're moved to a floating state, they have the default metro theme again.

I did some testing with the sample application, and I could reproduce the issue there however. If I moved a window that had a drop shadow, the CPU usage went way up. If I switched to classic theme, the CPU usage remained low. 

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

To set an application theme, you want to set ThemeManager.CurrentTheme in your app startup, ideally prior to any UI (e.g. windows) being referenced.

Hmm, I'm not seeing anything other than a small bump in CPU during movement of windows with the shadow.  If you'd like to remove the outer glow for all windows, please add this to your app's Resources:

<system:Boolean x:Key="{x:Static themes:AssetResourceKeys.WindowHasOuterGlowBooleanKey}">False</system:Boolean>
<Thickness x:Key="{x:Static themes:AssetResourceKeys.WindowResizeBorderNormalThicknessKey}">4</Thickness>

That will remove the shadow and put in a 4px resize border.


Actipro Software Support

The latest build of this product (v24.1.3) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.