Bug 49469 - DatePicker creation is slow
Summary: DatePicker creation is slow
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.3.3
Hardware: Macintosh Mac OS
: Normal enhancement
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-12-09 17:12 UTC by guhedvgo-lol
Modified: 2017-06-19 23:10 UTC (History)
4 users (show)

Tags: DatePicker iOS Performance
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description guhedvgo-lol 2016-12-09 17:12:02 UTC
I have a Page where multiple (6 Picker) TimePicker and DatePickers are created. On Xamarin Forms iOS this slows down the Page creation. I think I found the reason for this slowdown: https://github.com/xamarin/Xamarin.Forms/blob/74cb5c4a97dcb123eb471f6b1dffa1267d0305aa/Xamarin.Forms.Platform.iOS/Renderers/DatePickerRenderer.cs#L39

It seems that creating a new UIDatePicker is in general slow (about 55ms on iPhone 5s): _picker = new UIDatePicker { Mode = UIDatePickerMode.Date, TimeZone = new NSTimeZone("UTC") };

I think a solution could be to cache/make a copy or sth. like that of the UIDatePicker { Mode = UIDatePickerMode.Date, TimeZone = new NSTimeZone("UTC") }; and reuse this object for later creations?

Or maybe there are other ideas?
Comment 1 adrianknight89 2016-12-10 23:07:55 UTC
Why do you need to show multiple pickers? How many DatePickers are you showing? And how are you showing them? A repro would be nice to look at.
Comment 2 guhedvgo-lol 2016-12-12 12:05:09 UTC
Hi,thanks for your answer.

Why do you need to show multiple pickers? 

It's a time tracking app, so I need start date (DatePicker), end date (DatePicker), start time (TimePicker), end time(TimePicker) and pause time(TimePicker).

How many DatePickers are you showing? 
5 Picker.

And how are you showing them?
I made a new project, which shows the general structure of my app. In MainPage.xaml.cs I stop the time, how long it takes to show a page without Pickers (fast) and with 5 Pickers (about 250 ms on iPhone 5s, slower on iPhone 5, 4s, ...). When you uncomment one of the 5 Pickers you can see that the Page displays faster for every uncommented Picker.
Comment 3 adrianknight89 2016-12-30 02:23:46 UTC
- Have you tried XAML compile?

- How does it behave without XAML? I briefly looked at your repro. It'll be easier to test it if it doesn't use XAML.
Comment 4 Samantha Houts [MSFT] 2017-06-19 23:10:10 UTC
Using C# instead of XAML, it looks like it's an average of 27ms per DatePicker renderered.

As mentioned in Comment 0, UIDatePickers are notoriously expensive on iOS.

Since this performance issue is not specific to Xamarin.Forms, I am not sure that it qualifies as a bug. A resolution to the speed issue could be considered as an enhancement to the product, however, and could be submitted to the Evolution forum. https://forums.xamarin.com/categories/xamarin-forms-evolution

Thank you!