This is a migrated thread and some comments may be shown as answers.

Rate-governing Thumbnail updates?

1 Answer 49 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Iron
Iron
David asked on 02 May 2016, 04:46 PM

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?

 

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 05 May 2016, 11:17 AM
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.

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Diagram
Asked by
David
Top achievements
Rank 1
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or