Friday, October 12, 2012

Google Chrome Silverlight Performance Is Significantly Slow

Google Chrome Silverlight Performance Is Significantly Slow

Chrome Silverlight rendering is very slow (estimation: 10 times slower) comparing to firefox and internet explorer. You can test this simply using following sample code. Sample code demonstrates 15000 random data rendering inside a data grid.

Do you have any opinion why this is happening? There are 2 speculations came to my mind.

  1. Google does not want Microsoft's Silverlight gather wide usage on their platform.
  2. Chrome's infrastructure somehow causes plugin rendering slow.

XAML part:

<UserControl x:Class="sample.view.MemberView"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"         xmlns:viewmodel="clr-namespace:sample.ViewModel"     mc:Ignorable="d"     >     <UserControl.Resources>         <viewmodel:MemberViewModel x:Key="viewModel"/>     </UserControl.Resources>     <Grid x:Name="LayoutRoot" VerticalAlignment="Stretch" DataContext="{Binding Source={StaticResource viewModel}}">         <Grid.RowDefinitions>             <RowDefinition></RowDefinition>             <RowDefinition Height="35"></RowDefinition>         </Grid.RowDefinitions>         <data:DataGrid BorderThickness="1" ItemsSource="{Binding Members}" VirtualizingStackPanel.VirtualizationMode="Recycling">             <data:DataGrid.Columns>                 <data:DataGridTextColumn Header="Name" Width="3*" Binding="{Binding FirstName}"/>                 <data:DataGridTextColumn Header="Surname" Width="3*" Binding="{Binding LastName}"/>                 <data:DataGridTextColumn Header="GSM" Width="3*" Binding="{Binding MobilePhone}"/>                 <data:DataGridTextColumn Header="Email" Width="3*" Binding="{Binding Email}"/>                 <data:DataGridTextColumn Header="BirthDate" Width="2*" Binding="{Binding BirthDate}}"/>             </data:DataGrid.Columns>         </data:DataGrid>         <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1">             <Button Content="Get Random Data" Width="120" Height="25" Margin="5" Command="{Binding GetRandomDataCommand}"/>         </StackPanel>     </Grid> </UserControl> 

C# Part:

using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Net; using System.Text; using System.Windows; using System.Windows.Browser; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes;  namespace sample.ViewModel {     public class MemberModel     {         public string FirstName { get; set; }          public string LastName { get; set; }          public string MobilePhone { get; set; }          public string Email { get; set; }          public DateTime BirthDate { get; set; }     }      public class MemberViewModel     {         private List<MemberModel> _members;         public List<MemberModel> Members         {             get             {                 return _members;             }             set             {                 _members = value;                 RaisePropertyChanged(new PropertyChangedEventArgs("Members"));             }         }         public MyCommand GetRandomDataCommand { get; set; }          public MemberViewModel()         {             GetRandomDataCommand = new MyCommand();         }     }      public class MyCommand : ICommand     {         public bool CanExecute(object parameter)         {             return true;         }          public event EventHandler CanExecuteChanged;          private static Random random = new Random();         public void Execute(object parameter)         {             List<MemberModel> members = new List<MemberModel>();             for (int i = 0; i < 15000; ++i)             {                 MemberModel m = new MemberModel();                 m.FirstName = GetRandomString(random.Next(5) + 4);                 m.LastName = GetRandomString(random.Next(5) + 4);                 m.Email = GetRandomString(random.Next(10) + 4);                 m.MobilePhone = GetRandomString(random.Next(12));                 m.BirthDate = DateTime.Now.AddYears(-random.Next(50) - 18).AddMonths(random.Next(12)).AddDays(random.Next(30));                 members.Add(m);             }         }          private string GetRandomString(int length)         {             StringBuilder srb = new StringBuilder();             for (int i = 0; i < length; ++i)             {                 srb.Append((char)(65 + random.Next(29));             }             return srb.ToString();         }     }  } 

Answers & Comments...

Answer: 1

Merhaba,

A couple of days ago I encountered a msdn page. It says for Silverlight support x64 just for IE. Safari and Chrome browsers supported as x86. As a result of that you are right. Beside this AFAIK firefox has not a x64 setup.

But for Silverlight 5 things may changed.

I offer IE, Microsoft also :)

by : Davut Gürbüzhttp://stackoverflow.com/users/413032

Answer: 2
  1. Google does not want Microsoft's Silverlight gather wide usage on their platform.
    A: From my experience, this is not a problem on Google side. I had same problem as you describe for a couple weeks before I sent an email to Microsoft support and they suggested me to use IE. They did not answer me why it works so slow on Chrome.

  2. Chrome's infrastructure somehow causes plugin rendering slow.
    A: Again, this is not true at all. This problem comes from Microsoft. It seems like it does not care about Silverlight anymore. We plan to move our product to ASP.NET MVC for this reason too.

by : Ekkhttp://stackoverflow.com/users/849387




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog