Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance in dialogs #26

Open
gabrielittner opened this issue Apr 22, 2013 · 5 comments
Open

performance in dialogs #26

gabrielittner opened this issue Apr 22, 2013 · 5 comments
Labels

Comments

@gabrielittner
Copy link

When I place times-square into an AlertDialog or DialogFragment, it's performance get worse. When you select a new date the old selection disappears some time after the new appears, which makes the experience in using it fairly bad.

@edenman
Copy link
Collaborator

edenman commented Apr 23, 2013

We haven't done any work on using this view in a dialog (and frankly, probably won't invest much in this). Pull requests welcome!

@gabrielittner
Copy link
Author

I investigated the issue a little. When the view is in a DialogFragment on each notifyDataSetChanged and also on the first time the view is drawn, getView is called multiple times for each row view.

Here is how the log looks for the first initialization (I added a log for the case that the row view has to be inflated):

DEBUG/TimesSquare(2374): Creating MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Creating MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Creating MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='April 2013', month=3, year=2013}
DEBUG/TimesSquare(2374): Creating MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='May 2013', month=4, year=2013}

This is the log for the sample app:

DEBUG/TimesSquare(2374): Creating MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='February 2013', month=1, year=2013}
DEBUG/TimesSquare(2374): Creating MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='March 2013', month=2, year=2013}
DEBUG/TimesSquare(2374): Creating MonthView for MonthDescriptor{label='April 2013', month=3, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='April 2013', month=3, year=2013}
DEBUG/TimesSquare(2374): Initializing MonthView for MonthDescriptor{label='May 2013', month=4, year=2013}

I don't have any idea why this is happening, but will try to find the reason tomorrow.

@edenman
Copy link
Collaborator

edenman commented May 27, 2013

@gabrielittner I did a little work on this today (#52) and found one slight optimization, but the root cause still eludes me (I'm on a plane and don't have the android src on my new laptop so I can't step through the OS code to figure out what's causing the re-measure). Let me know if you find/found anything out.

@edenman
Copy link
Collaborator

edenman commented Jan 6, 2014

I just banged on this again some more: hierarchyviewer shows that some of the parent views in the custom dialog (customPanel/parentPanel in particular) have height = WRAP_CONTENT. I tried overriding that to MATCH_PARENT but that didn't help. Android still really wants to measure and re-measure the child views for some reason. I tried digging around in the android layout code but this time I don't have the right version of the android source on my computer so none of the line numbers match up. Giving up on this for now. @JakeWharton any ideas?

@serenskye
Copy link

I think this might be related I'm having similar issues in an Activity, I get this log over and over again. I can't highlight a selection range more than two without them all unselecting and performance is very laggy.
05-13 11:11:15.602 4699-4699/com.app W/View﹕ requestLayout() improperly called by com.squareup.timessquare.CalendarCellView{430e0020 V.ED..C. ......ID 0,0-85,85} during layout: running second layout pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants