title: Why is Xamarin.Forms so slow when displaying a few labels (especially on Android)?
body: <p>We are trying to release some productive Apps with Xamarin.Forms but one of our main issues is the overall slowness between button pressing and displaying of content. After a few experiments, we discovered that even a simple <code>ContentPage</code> with 40 labels take more than 100 ms to show up:</p>
  
  <pre><code>public static class App
  {
      public static DateTime StartTime;
  
      public static Page GetMainPage()
      {    
          return new NavigationPage(new StartPage());
      }
  }
  
  public class StartPage : ContentPage
  {
      public StartPage()
      {
          Content = new Button {
              Text = "Start",
              Command = new Command(o =&gt; {
                  App.StartTime = DateTime.Now;
                  Navigation.PushAsync(new StopPage());
              }),
          };
      }
  }
  
  public class StopPage : ContentPage
  {
      public StopPage()
      {
          Content = new StackLayout();
          for (var i = 0; i &lt; 40; i++)
              (Content as StackLayout).Children.Add(new Label{ Text = "Label " + i });
      }
  
      protected override void OnAppearing()
      {
          ((Content as StackLayout).Children[0] as Label).Text = "Stop after " + (DateTime.Now - App.StartTime).TotalMilliseconds + " ms";
  
          base.OnAppearing();
      }
  }
  </code></pre>
  
  <p>Especially on Android it get's worse the more labels you're trying to display. The first button press (which is crucial for the user) even takes ~300 ms. We need to show something on the screen in less than 30 ms to create a good user experience.</p>
  
  <p>Why does it take so long with <code>Xamarin.Forms</code> to display some simple labels? And how to work around this issue to create a shippable App?</p>
  
  <p><strong>Experiments</strong></p>
  
  <p>The code can be forked on GitHub at <a href="https://github.com/perpetual-mobile/XFormsPerformance">https://github.com/perpetual-mobile/XFormsPerformance</a></p>
  
  <p>I've also written a small example to demonstrate that similar code utilizing the native APIs from Xamarin.Android is significantly faster and does not get slower when adding more content: <a href="https://github.com/perpetual-mobile/XFormsPerformance/tree/android-native-api">https://github.com/perpetual-mobile/XFormsPerformance/tree/android-native-api</a></p>