Rate-governing Thumbnail updates?

2 posts, 0 answers
  1. David
    David avatar
    31 posts
    Member since:
    Jan 2013

    Posted 02 May 2016 Link to this post

    We notice some fairly significant performance slow-down as we initialize our diagram (specifically when switching what the diagram shows and doing mass additions/removals).  The Thumbnail seems to be creating lots of WriteableBitmaps over and over at that time (specifically in BitmapUtils.CreateWriteableBitmap).  This seems to happen the first time we use the diagram (say, 40+ invocations of CreateWriteableBitmap) but only once thereafter when we do wholesale changes of what we show in the diagram.

    I initially thought it's something we do, but I don't find any difference between the first time we populate the diagram with shapes and subsequent times.

    The call to CreateWriteableBitmap is triggered (ultimately, through several steps) by RadDiagramThumbnail.DeferredRefresh.

    1) Is there any built-in functionality to limit the rate at which Thumbnail updates itself?  If not, do I read the documentation correctly that we should expect to be able to use IsAutoRefreshEnabled and RefreshThumbnail to rate-limit the Thumbnail refreshes ourselves?

    2) Any advice for further tracing/debugging why we see so many calls only the first time we populate the Diagram?  Or, other things that we might be doing differently between the first time we populate Diagram and subsequent times?


  2. Martin Ivanov
    Martin Ivanov avatar
    1594 posts

    Posted 05 May 2016 Link to this post

    Hello David,

    Thank you for the description.

    Let me start with that RadDiagram supports UI virtualization. This means that only the elements in the visible area of the diagram (the viewport) will be displayed in the visual tree, thus improving the performance when it comes to interactions with the control (pan, zoom, etc.). But, the virtualization kicks in after the diagram elements are loaded initially and their containers are generated. Probably this is the reason why the diagram is slower when loading the first items, which I guess are in larger amount than the items added subsequently. 

    However, when the diagram thumbnail is included there is a peculiarity which you should keep in mind. The thumbnail shows the diagram shapes with images which are created with the BitmapUtils.CreateWriteableBitmap() method. The method is called many times because the thumbnail control listens for changes in the visual children of the diagram. Each time an item is added in the diagram, the thumbnail stops the UI virtualization and makes a snapshot (and image) of all diagram elements. Then it enables the virtualization again. In a scenario with many elements this is quite slow operation. You can improve the performance by using the approach that you mentioned in point the question from your reply marked as 1. Basically, when you start adding new items in the diagram you can set the IsAutoRefreshEnabled property of the thumbnail to false. This will prevent it from updating, and therefore creating new images. After the items are added you can call the RefreshThumbnail() method which will create snapshots of the diagram items and display them in the thumbnail. 

    I hope this information is useful.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top