Performance problem when resizing application

Docking/MDI for WPF Forum

Posted 2 years ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Version: 21.1.3
Platform: .NET 5.0
Environment: Windows 10 (64-bit)
Avatar

Hi,

we are currently upgrading from version 19.1.687 to 21.1.3 and I have noticed that resizing the application is considerbly slower. I used the profiler to dig a little deeper and found out that the problem only occurs with visible WindowsFormHost instances.

100,00 %   Arrange  •  4.903 ms  •  System.Windows.UIElement.Arrange(Rect)
  100,00 %   ArrangeCore  •  4.903 ms  •  System.Windows.FrameworkElement.ArrangeCore(Rect)
    99,31 %   ArrangeOverride  •  4.870 ms  •  System.Windows.Forms.Integration.WindowsFormsHost.ArrangeOverride(Size)
      80,30 %   RunTranslator  •  3.937 ms  •  System.Windows.Forms.Integration.PropertyMap.RunTranslator(PropertyTranslator, Object, String, Object)
        80,30 %   BackgroundPropertyTranslator  •  3.937 ms  •  System.Windows.Forms.Integration.WindowsFormsHostPropertyMap.BackgroundPropertyTranslator(Object, String, Object)
          79,93 %   GetBitmapForTransparentWindowsFormsHost  •  3.919 ms  •  System.Windows.Forms.Integration.HostUtils.GetBitmapForTransparentWindowsFormsHost(WindowsFormsHost)
            56,91 %   GetBitmapForFrameworkElement  •  2.791 ms  •  System.Windows.Forms.Integration.HostUtils.GetBitmapForFrameworkElement(FrameworkElement)
              56,91 %   GetRenderTargetBitmapForVisual  •  2.791 ms  •  System.Windows.Forms.Integration.HostUtils.GetRenderTargetBitmapForVisual(Int32, Int32, Visual)
                53,84 %   Render  •  2.640 ms  •  System.Windows.Media.Imaging.BitmapVisualManager.Render(Visual)
                  53,84 %   Render  •  2.640 ms  •  System.Windows.Media.Imaging.BitmapVisualManager.Render(Visual, Matrix, Rect)
                    53,84 %   Render  •  2.640 ms  •  System.Windows.Media.Renderer.Render(IntPtr, Channel, Visual, Int32, Int32, Double, Double, Matrix, Rect)
                      3,34 %   Render  •  164 ms  •  System.Windows.Media.Visual.Render(RenderContext, UInt32)
                      2,16 %   Commit  •  106 ms  •  System.Windows.Media.Composition.DUCE+Channel.Commit
                      1,22 %   ReleaseOnChannel  •  60 ms  •  System.Windows.Media.Visual.ReleaseOnChannel(Channel)
                      0,33 %   Precompute  •  16 ms  •  System.Windows.Media.Visual.Precompute
                2,91 %   RenderTargetBitmap..ctor  •  143 ms  •  System.Windows.Media.Imaging.RenderTargetBitmap..ctor(Int32, Int32, Double, Double, PixelFormat)
                0,16 %   PixelsPerInch  •  8 ms  •  System.Windows.Forms.Integration.HostUtils.PixelsPerInch(Orientation)
            23,02 %   GetBitmapFromRenderTargetBitmap  •  1.129 ms  •  System.Windows.Forms.Integration.HostUtils.GetBitmapFromRenderTargetBitmap(Control, RenderTargetBitmap, Point)
          0,37 %   SetBackgroundImage  •  18 ms  •  System.Windows.Forms.Integration.HostUtils.SetBackgroundImage(WinFormsAdapter, Control, Bitmap)
      18,85 %   set_Size  •  924 ms  •  System.Windows.Forms.Control.set_Size(Size)
      0,16 %   ScaleChild  •  8 ms  •  System.Windows.Forms.Integration.WindowsFormsHost.ScaleChild
    0,18 %   SetLayoutOffset  •  9 ms  •  System.Windows.FrameworkElement.SetLayoutOffset(Vector, Size)
    0,18 %   GetDpi  •  9 ms  •  System.Windows.Media.Visual.GetDpi
    0,16 %   ArrangeOverride  •  8 ms  •  ActiproSoftware.Windows.Controls.Docking.AdvancedTabControl.ArrangeOverride(Size)
    0,00 %   10 functions hidden  •  0 ms total
  0,16 %   OnRender  •  8 ms  •  System.Windows.Controls.TextBlock.OnRender(DrawingContext)

Do you have any idea how we can fix that?


Best regards, Tobias Lingemann.

Comments (3)

Posted 2 years ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Fyi, the callstack in the previous version was completely different:

27,84 %   OnPrimaryWindowSizeChanged  •  2.038 ms  •  ActiproSoftware.Windows.Themes.WindowChromeShadow.OnPrimaryWindowSizeChanged(Object, SizeChangedEventArgs)
  27,84 %   Reposition  •  2.038 ms  •  ActiproSoftware.Windows.Themes.WindowChromeShadow.Reposition
    27,84 %   SetValueCommon  •  2.038 ms  •  System.Windows.DependencyObject.SetValueCommon(DependencyProperty, Object, PropertyMetadata, Boolean, Boolean, OperationType, Boolean)
      27,84 %   OnPropertyChanged  •  2.038 ms  •  ActiproSoftware.Windows.Themes.WindowChromeShadow.OnPropertyChanged(DependencyPropertyChangedEventArgs)
        27,84 %   OnPropertyChanged  •  2.038 ms  •  System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs)
          27,68 %   OnPropertyChanged  •  2.026 ms  •  System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs)
            27,50 %   [Native code]  •  2.013 ms
              17,44 %   _OnWidthChanged  •  1.277 ms  •  System.Windows.Window._OnWidthChanged(DependencyObject, DependencyPropertyChangedEventArgs)
                17,44 %   OnWidthChanged  •  1.277 ms  •  System.Windows.Window.OnWidthChanged(Double)
                  17,44 %   UpdateWidth  •  1.277 ms  •  System.Windows.Window.UpdateWidth(Double)
                    17,44 %   UpdateHwndSizeOnWidthHeightChange  •  1.277 ms  •  System.Windows.Window.UpdateHwndSizeOnWidthHeightChange(Double, Double)
                      ...
                        14,24 %   HandleMessage  •  1.042 ms  •  System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage, IntPtr, IntPtr)
                          14,24 %   OnResize  •  1.042 ms  •  System.Windows.Interop.HwndTarget.OnResize
                            14,24 %   CompleteRender  •  1.042 ms  •  System.Windows.Media.MediaContext.CompleteRender
                              14,24 %   SyncFlush  •  1.042 ms  •  System.Windows.Media.Composition.DUCE+Channel.SyncFlush
                                                    
              10,05 %   _OnHeightChanged  •  736 ms  •  System.Windows.Window._OnHeightChanged(DependencyObject, DependencyPropertyChangedEventArgs)
                10,05 %   OnHeightChanged  •  736 ms  •  System.Windows.Window.OnHeightChanged(Double)
                  10,05 %   UpdateHeight  •  736 ms  •  System.Windows.Window.UpdateHeight(Double)
                    10,05 %   UpdateHwndSizeOnWidthHeightChange  •  736 ms  •  System.Windows.Window.UpdateHwndSizeOnWidthHeightChange(Double, Double)
                      ...
                        8,89 %   HandleMessage  •  651 ms  •  System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage, IntPtr, IntPtr)
                          8,71 %   OnResize  •  638 ms  •  System.Windows.Interop.HwndTarget.OnResize
                            8,40 %   CompleteRender  •  615 ms  •  System.Windows.Media.MediaContext.CompleteRender
                              8,40 %   SyncFlush  •  615 ms  •  System.Windows.Media.Composition.DUCE+Channel.SyncFlush


Best regards, Tobias Lingemann.

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

Hi Tobias,

I believe in v20.1 or so we updated the ToolWindow and DocumentWindow controls to have a Transparent background.  While this is fine for WPF controls, we found it did cause a performance decrease in WindowsFormsHost that has a Transparent background.  You can see in the stack that GetBitmapForTransparentWindowsFormsHost takes up most of the time.

This documentation topic covers the issue in detail and tells you how to improve performance again like before:

https://www.actiprosoftware.com/docs/controls/wpf/docking/interop-compatibility

[Modified 2 years ago]


Actipro Software Support

Posted 2 years ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Thanks.


Best regards, Tobias Lingemann.

The latest build of this product (v24.1.1) 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.