Weird Lag Bug with Internet Explorer 9 + Silverlight 4 + MVVM Light - silverlight

I have a very weird bug when I try to debug when my silverlight application run under Internet Explorer 9 (RC). I use MVVM Light framework. (And I use a WCF WebService, but I guess this part isn't a issue)
I have two side effects/bugs:
When a breakpoint is hit and I pres F5, I have at least 5-8 sec of wait.(no reason).
Sometimes when I move my mouse anywhere my pc beeps (many short beeps) and my mouse moves very very slowly.
I run the same this on chrome or firefox without any problems.
I use MVVM Light Toolkit V3 SP1 (4).

Mb this http://mvvmlight.codeplex.com/workitem/7293 ?
Well anyway it seem that there is some "memory leek" or something like that... it dosen't crush IE but it gives a lot of trobles..
Try this. Create new empty project and try to add onle feature after another (one by one)... maybe this will help you to find where problem is..

I create a very small sample of this behaviour...
http://cid-9292b3e7504f952f.office.live.com/self.aspx/Public/MVVM%20Bug/MVVM%20Light%20Test%201.zip
Put beakpoint on this line ...
//TEST PUT Breakpoint here !!!!!!!!! each F10 take 3-5 sec ...
ListOfSample.Clear();

Related

Sudden fps drop during multi-touch

I have a WPF application showing a large image (1024x1024) inside a ZoomableCanvas. On top of the image, I have some 400 ellipses. I'm handling touch events by setting IsManipulationEnabled="True" and handling the ManipulationDelta event. This works perfectly when zooming slowly. But as soon as I start zooming quickly, there is a sudden frame-rate drop resulting in a very jumpy zoom. I can hear the CPU fan speeding up when this occurs. Here are some screenshots from the WPF Performance Suite at the time when the frame-rate drops:
Perforator
Visual Profiler
Software renderer kicks in?
I'm not sure how to interpret these values, but I would guess that the graphics driver is overwhelmed by the amount of graphics to render, causing the CPU to take over some of the job. When zooming using touch, the scale changes by small fractions. Maye this has something to do with it?
So far, I have tried a number of optimization tricks, but none seem to work. The only thing that seems to work is to lower the number of ellipses to around 100. That gives acceptable performance.
Certainly this is a common problem for zoomable applications. What can I do to avoid this sudden frame-rate drop?
UPDATE
I discovered that e.DeltaManipulation.Scale.X is set to 3.0.. in the ManipulationDelta event. Usually, it is around 1.01... Why this sudden jump?
UPDATE 2
This problem is definitely linked to multi-touch. As soon as I use more than one finger, there is a huge performance hit. My guess is that the touch events flood the message queue. See this and this report at Microsoft Connect. It seems the sequence Touch event -> Update bound value -> Render yields this performance problem. Obviously, this is a common problem and a solution is nowhere to be found.
WPF gurus out there, can you please show how to write a high performance multi-touch WPF application!
Well I think you've just reached the limits of WPF. The problem with WPF is that it tesselates (on CPU) vertex grafics each time it is rendered. Probably to reduce video memory usage. So you can imagine what happens when you place 600 ellipses.
If the ellipses are not resized then you could try to use BitmapCache option. In this way ellipses will be randered just once in the begining and then will be stored as textures. This will increase memory usage but should be ok I think.
If your ellipses are resized then previous technic won't work as each ellips will be rerendered when resized and and it will be even slower as this will rewrite textures (HW IRTs in perforator).
Another possibility is to design special control that will use RenderTargetBitmap to render ellipses to bitmaps and then will render it through Image control. In this way you can control when to render ellipses you could even render them in parralel threads (don't forget about STA). For example you can update ellipse bitmaps only when user interaction ends.
You can read this article about WPF rendering. I don't agree with the author who compares WPF with iOS and Android (both use mainly bitmaps compared to WPF). But it gives a good explanation about how WPF performs rendering.

Downloaded Panorama background image is cropped to screen size

If I set the Panorama.Background image brush source to a URL of a photo out on the internet, the image is centered and cropped, rather than starting at the left edge and bleeding off the screen to the right, widescreen style.
If I set the source as a local pack URI, its fine.
Smells like a bug.
Anyone got a simple workaround? Microsoft should be equipping us with a working SDK that allows us to create experiences at least as good as the phone's hubs.
Thanks!
UPDATE
The problem appears not to be images on the web, but images that are smaller than the screen size of the phone - all my web-hosted images are quite small for bandwidth reasons.
Taking my original background art 1024x768 and halving its size results in the phone cropping the right edge of the image.
UPDATE 2
Found someone else with the same problem:
http://forums.create.msdn.com/forums/p/78770/615061.aspx
UPDATE 3
http://www.lukepuplett.com/2012/05/windows-phone-panorama-background-image.html
Side-by-side images demonstrate the bug, clearly. I'll throw it over to Cliff on the team in Redmond and see what he thinks.
It's a problem I've found since my earliest days with the phone, and I assumed it'd be quite a well-known issue. So I expected people to quickly say "Oh yeah, that old chestnut, you need to do XYZ."
Thanks for the -3, everyone. Keep up the good work.
Before running around with "IT'S A BUG!" claims, I would do my research.
That being said, you are downloading an image, and most likely using a combo of BitmapImage/ImageBrush. Now, ImageBrush has a Stretch property and that is where you have to look.
The panorama background is intended to be a rich, high quality image.
I would expect what you're seeing ("inconsistent" resizing) if you're using an image smaller than the space you're filling and not specifying how it should be stretched.
If you're claiming a bug, what is the behaviour you're expecting?
Based on your blog post (liked in update 3) it seems you're expecting a different default stretch behaviour for an image when used in the background in a panorama. As a general rule, introducing inconsistencies or conditional defaults is likely to introduce more confusion and work in the long run.

Lagging silverlight app

I've been playing around with Silverlight 5 and started putting together a little game. It's nothing special and it's purely to just play around.
If you look at the link below you'll notice that it's lagging a bit.
Link(Just use the arrow keys): http://www.netauto.co.za/WIP/GameTest.html
Basically I'm using a Storyboard to scroll the road and move the cars on the screen with every tick. At first I used the CompositionTarget.Rendering, but I was having the same problem. So I thought I'll try a Storyboard, but it made no difference.
There is a second timer that adds a vehicle in a random lane with every tick. They get removed once they go off screen. Disabling this timer makes no difference.
CPU usage is almost none. Also tried it on another PC and it was exactly the same.
I would post some code, but there's quite a bit of it and as I'm just fooling around it's a bit of a mess 0.o
Any ideas on how I can move the objects around without that lag?
I'm using Silverlight 5.
Thank you
You can try to use BitmapCache on the scrolling road and cars, if you are not already. This can cut down on the traffic to the GPU.
More links: One, Two.

How to know why an animation stutters?

I have a few fairly simple animations (moving text around, moving ellipses etc.) and running in full screen (1920x1080 minus the task bar) the WPF Performance Suite reports a good framerate around 50 FPS throughout the animation. Dirty Rect Addition is somewhere around 300 rect/s, the SW frames are between 0 and 4 and the HW frames are between 3 and 5. Video memory usage is around 80 MB.
Problem is that the animations stutters every other half second. It is definitely not fluid :-(
My machine is a new Dell laptop XPS 15 with the GeForce GT 435 with 2GB memory. - The drivers are up to date. (The same behavior occurs on my netbook (in full screen) as well so I don't think it is hardware related.)
If I make the window smaller the stutter goes away.
The stutter occurs with the simplest of animations - even with just a couple of elements but adding more elements certainly makes it more noticeable.
How can I find out what causes this stutter?
When I think of it, I have not actually seen any WPF animations which run smoothly in full screen. Is this even possible?
Have you tried to set a lower "max frame rate" to the animation?
<Storyboard Timeline.DesiredFrameRate="10">
<!-- ....blah blah blah -->
</Storyboard>
If your animation is causing massive recalculation of child or parent elements, changing the DesiredFrameRate will have a cascading effect on the number of calculations made by the system.
Also, check out the "Remarks" section of this link. It explains why/when you should use it.
If setting a lower frame rate fixes your stuttering, then you need to consider simplifying your XAML to limit the amount of recalculation needed at every frame of your animation (limiting the number of child or parent objects resized - or affected in any way - by every frames/changes made by the animation.
You might want to also check out the "WPF Performance Suite". It is an awesome set of tools to determine what exactly is going on in your WPF app, seeing which parts of your window are being repainted and when, and the CPU usage of each of your XAML elements!
Hope this helps!
Patrick,
I have no answers. All I can do is provide some solidarity. I'm trying to animate an ItemsControl. The concept is pretty simple, really. I've got a ListView and in the ListView I have a GridView. I want the items in the GridView to to smoothly go from one row to another row as the underlying list is sorted so that, for example, a sorted list will stay sorted as the values in the list change.
I've noticed this: animation on moderately complex controls is a CPU hog. The stuttering I'm pretty sure is simply related to the CPU being maxed out (I noticed you didn't provide the CPU graph on your dump above). Keep the CPU around 50% and the animation appears smooth, above 75% and you get these stutters.
Still working on the problem, but I think it goes deeper than my code.
Don
I had a similar issue where it was stuttering, nothing really major it just looked like little stutters here and there while I ran the program. On a hunch, I shut down Google Chrome while it was running and that fixed it,the scrolling became completely smooth...
So my advice would be if you have any internet browsers open check to see if closing them out fixes the problem.

Printing text from silverlight application

I'm trying to print a report (just text in columns) from my Silverlight 4 application. The only way I know about is to use PrintDocument and set the PageVisual to a framework element showing the report. However, this results in an insanely large print job (like 120 MB). This is not what my customer wants. Is there any other solution?
The problem with Silverlight 4 is that everything you go to print is produced as a rasterized image at 600 DPI. This explains the large job size you are seeing. This is also why text from Silverlight can look very fuzzy compared to what you'd expect from your output. Silverlight 5 will address this with Postscript vector-based printing, but for now you are facing the reality that without third-party solutions you are effectively stuck with the out of the box limitations or using HTML.
If you are willing to generate the report from HTML being served server-side you may have the best solution considering what you're doing. In that case you would at least not have to worry about complexities like pagination as part of printing from Silverlight.
A good third-party solution for reporting, but perhaps more than what you need, is to use Reporting Services coupled with this product: http://www.perpetuumsoft.com/Silverlight-Viewer-for-Reporting-Services.aspx?lang=en
One easy solution is to print web page directly from browser (I assume this is not what you want).
I think the PrintDocument and PageVisual is the only way how to print from inside of SL.
I did some printing even with large visual structures, but I haven't checked how large my print job is, so I can't tell you if it is normal or not.
Anyway, you can try not to print directly the element you want to print, but made some other lightweight one which will serve only for printing purposes and fill it with same data and print that lightweight element.
You can convert your text into picture and then print picture.. mb this will help you
http://www.andybeaulieu.com/Home/tabid/67/EntryID/161/Default.aspx
http://www.snowball.be/Printing+In+Silverlight+3+Yes+We+Can.aspx

Resources