Silverlight bug when drawing large paths

I’m working on creating a zoom effect for a Silverlight Path object. This effect is easy to implement: I just have to apply a ScaleTransform and and a TranslateTransform within a TransformGroup for the Path (scale it up and move it on the screen where the user clicked to zoom). However when reaching a certain zoom level I’ve noticed some weird behaviour: the Path was drawn in some random, sometimes inverse way.

I’ve tracked the behaviour down to the point to when it seems that the problem is not with ScaleTransform but with Paths above a certain size. I’ve created a simple example project to reproduce the problem. The source can be downloaded here.

What I’m doing is drawing a simple rectangle with 5 points:
11

The issue

And I start to redraw it in larger sizes and at the same time re-positioning it to stay in the center (so I’m basically doing a centre zoom effect):
21

However when the size of the path is about 65 000px (or 80 times the height of the LayoutRoot – I used 1280*1024 resolution with the LayoutRoot grid being about 770px) the shape is drawn incorrectly:
3

Note: the point where the shape is drawn incorrectly seemed to vary on the size of the window (both width and height), when set to really small it started to happen at about 63000px but I could not find a real corelation between window size and when this appearance started to happen. In IE8 with 1280×1024 it was 80x screen height (or 65 120px) where this behaviour was noticed.

At 83x height on my computer (at 67 562px) the path was rendered like this:
4

It stayed like this until about 160x screen height (130 240 px) when it started to “shrink”:
5

And finally at about 161.8x (131 705 px) the middle of the screen was starting to get normal with the strange behaviour moving up and left probably causing troubles elsewhere:
6

This behaviour is periodical so on my computer I’ve noticed it happen again and again at 240x screen height (195 360 px), 320x screen height (260 480 px) and so on.

Reproducing the bug

The below steps are guidelines among which hopefully this strange behaviour can be reproduced:

  • Download, compile and run the here.
  • If possible, set your resolution to 1280×1024. If not, you’ll probably have to do some playing around at the screen size the issue happens
  • Set “Square size” to “80”, click on the “Apply” button next to it. You should see the drawing on the second picture. If your screen resolution is under 1280×1024 you’ll probably have to enter a smaller number than 80x, if it’s a higher resolution, you might have to increase this number
  • Play around by increasing the multiplier and the shape should render similar to the images I’ve attached.

Workaround

As a temporary workaround I’m limiting paths to be enlarged up to 40 000 px – the problem only seemed to occur around 65 000 px. Should anyone be aware of any other workaround or the issue being resolved please leave a comment.

(Note: this post is also intended to be a detailed bugreport for the Silverlight team.)

One Response to Silverlight bug when drawing large paths
  1. [...] ran into the issue of Silverlight displaying large elements incorrectly in version 3. After reporting th... gregdoesit.com/2010/04/silverlight-still-displaying-large-elements-buggy