Sunday, June 20, 2010 11:18 PMI have a Silverlight application (running SL 4). I am experiencing dramatic performance differences on one aspect of the application. The functionality which produces the difference is a search algorithm which, more or less does between 10-70,000 string compares based on the size of the object being searched. This occurs on the UI Thread in a Text Changed event handler (i.e. TextBox text changed produces the search results), and the method returns the top 25 results which get populated into a ListBox. On PC. I've gotten results to return anywhere from 24-90ms with the UIElements being generated fast enough to not worry about this occurring on the UI Thread, but on Mac it completely blocks the UI Thread. I've let it run for an hour without any results being returned. I looked at CPU usage and it sky rockets to anywhere from 85-99%. Literally the only thing this is doing is iterating through the object's fields (using foreach) and doing a string comparison for each of the objects inside. I would look for it getting stuck in a loop, but I'm not really worried about foreach enumerations bounds getting screwed up, and it runs fine on PC. Is the CLR optimizing my code differently for Mac and Pc? If so- what do I do?
Monday, June 21, 2010 4:27 AM
I can't help you on inverstigating rhe issue but I suggest (obviously) to move the hard stuff to a BackgroudWorker to save the User Experience.
Monday, June 21, 2010 9:47 AM
I work with the original poster -- because the operation finishes within ~50ms putting this operation on a different thread isn't necessary. I am more interested in knowing why the same C# code behaves differently (and hangs) on Mac versus PC. There are no calls to the Browser DOM or third-party libraries at work. It is C# and Silverlight. Has anyone seen this before? Can we rule out the GPU when SL is in-browser because it is using software rendering?
Monday, June 21, 2010 2:25 PM
Hi jmblakl, I'm really interested in better understanding your issue.
Can you share out source code that I can build and profile on our end? You can use SkyDrive to share out the code.
Monday, June 28, 2010 11:03 AM
Sorry I haven't gotten back to you on this till now. I actually found the issue, and the fix is already in production. It was related to the StringComparison type I was using. Apparently StringComparison.CurrentCultureIgnoreCase was causing the issue -- I changed it to OrdinalIgnoreCase and it's been working fine.
Tuesday, October 05, 2010 3:33 AM
Hey Mike. I just came across this issue myself, and I have prepared a small sample project where the issue is reproducable. There are some comments in the code to explain what is going on. Both the Mac and the PC we have tested this on are running Silverlight version 4.0.50917.0.
Here is the project:
Oh, and thanks a bunch to jmblakl for posting the solution. Without that we would have been stuck with this until christmas.
Thursday, October 07, 2010 7:05 AM
FYI: I have reported this bug at Microsoft Connect.
Friday, October 08, 2010 3:23 PM
Fantastic, thanks for putting together a repro Henrik, this will save us a lot of time! I'll make sure the issue gets routed to the appropriate person.