Skip to content

Conversation

@OvrBtn
Copy link

@OvrBtn OvrBtn commented Oct 18, 2024

Description of Change

This PR is an addition to #24948 and it further improves performance of first render of DatePicker by creating DatePickerDialog on demand instead of on control render.

Issues Fixed

Fixes #24929

Blockers

This PR should be merged after #20547 is merged since it might break workarounds like this one #12899 (comment)

@OvrBtn OvrBtn requested a review from a team as a code owner October 18, 2024 01:56
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 18, 2024
@dotnet-policy-service
Copy link
Contributor

Hey there @OvrBtn! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@OvrBtn OvrBtn changed the title Create DatePickerDialog on demand [Android] Create DatePickerDialog on demand Oct 18, 2024
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@OvrBtn
Copy link
Author

OvrBtn commented Oct 18, 2024

Failing tests don't seem related.

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has some good things, but I feel like it is working with bad source code. Maybe check to see if the whole dialog can be created on demand when it is about to appear.

Comment on lines -28 to +23
internal DatePickerDialog? DatePickerDialog { get { return _dialog; } }
internal DatePickerDialog? DatePickerDialog { get { return _dialog ??= CreateDefaultDatePickerDialog(); } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just create the dialog in ShowPickerDialog like the time picker? I also see that in time picker, we always re-create the dialog:

void ShowPickerDialog(int hour, int minute)
{
	_dialog = CreateTimePickerDialog(hour, minute);
	_dialog.Show();
}

I see we do set some values in the mappers for the min/max dates, but I feel like that was wrong as we can totally set this in the setDateLater part of the ShowPickerDialog just like we set the actual date.

I think this whole setup should rather be a lazy loading thing and we set the min/max when the picker is about to appear.

Comment on lines +81 to +85
if (VirtualView != null)
{
dialog.DatePicker.MaxDate = (long)VirtualView.MaximumDate.ToUniversalTimeNative().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
dialog.DatePicker.MinDate = (long)VirtualView.MinimumDate.ToUniversalTimeNative().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, maybe no need to the setLater as you do it here. In this case, we can use a totally lazy creating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-datetimepicker DatePicker, TimePicker community ✨ Community Contribution platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance] DatePicker/TimePicker first render is too slow

3 participants