Closed Bug 921685 Opened 11 years ago Closed 11 years ago

contacts auto-detection of "rows per screen" causes sync reflow

Categories

(Firefox OS Graveyard :: Gaia::Contacts, defect, P1)

ARM
Gonk (Firefox OS)
defect

Tracking

(blocking-b2g:koi+, b2g-v1.2 fixed)

RESOLVED FIXED
1.2 C4(Nov8)
blocking-b2g koi+
Tracking Status
b2g-v1.2 --- fixed

People

(Reporter: bkelly, Assigned: bkelly)

References

Details

(Keywords: perf, Whiteboard: [c=progress p=3 s= u=1.2])

Attachments

(1 file)

While profiling bug 914913 I noticed that we are triggering a sync reflow during load due to the code that auto-detects the number of rows that will fit in a single page on the device.  This is due to getBoundingClientRect() in appendToList().  The reflow is fairly small and contained, taking about 10ms to 20ms, but it would be nice to remove it if we could.

I'm not sure what to do about this one.  It seems detecting the page size is a legitimate thing to do given that we have devices with different dimensions.  The most reliable way to do this is based on the final calculated CSS style.

Perhaps we could set a "minimum page size" reflecting our smallest handsets and defer calculating the true rowsPerPage value until we've rendered at least that many contacts.  This could at least help our time to display the first page of contacts on these smaller handsets.

I'm open to other suggestions too.
could we do this with window.innerHeight or via a prefilled value at build time?
(In reply to Jose M. Cantera from comment #1)
> could we do this with window.innerHeight or via a prefilled value at build
> time?

So its not the determining the viewport size that is the issue, but instead determining how large each row is.  We can either get the row size specifically or the full list size and then divide by number of rows, but either way we cause a sync flush in order to calculate the actual size.  (Row vs full list should be pretty equivalent at the moment, by the way, because we do it when we only have one item in the row.)

Prefilled at build time would be possible, but would be kind of a pain for testing.

I suppose we could cache it in the cookie along with the list ordering.  On its own that would seem a bit over the top, but since we're looking at the cookie anyway...
Taking this one to try to further improve 914913.  I'm going to pursue the cookie path since we already have a config value stored there.  Since the geometry of the device is fixed we should only have to pay the sync reflow price once.
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
Work in progress on this branch.

  https://github.com/wanderview/gaia/compare/contacts-size-reflow?expand=1

So far I have just refactored the cookie code a bit to allow me to insert additional values.
Nom koi? since this koi+ block 914913.
blocking-b2g: --- → koi?
Work-in-progress branch has been updated.  This appears to be working and I've verified in the profiler that the sync reflow is avoided.  Just need to clean up for review.
blocking-b2g: koi? → koi+
Whiteboard: [c= p= s= u=] → [c=progress p= s= u=1.2]
Priority: -- → P1
This pull request avoids the sync reflows from rowsPerScreen detection by storing detected value in the cookie.
Attachment #821205 - Flags: review?(jmcf)
Hi Ben,

The PR is in good shape, though I left some comments on Github.
Thanks Jose.  I've updated the pull request based on your suggestions.  Let me know what you think.
Comment on attachment 821205 [details] [review]
Pull request at https://github.com/mozilla-b2g/gaia/pull/13043

Moving the r? to Francisco since Jose is out on PTO.
Attachment #821205 - Flags: review?(jmcf) → review?(francisco.jordano)
Whiteboard: [c=progress p= s= u=1.2] → [c=progress p=3 s= u=1.2]
Just to note I'm back and could resume the review if you agree

thanks
Comment on attachment 821205 [details] [review]
Pull request at https://github.com/mozilla-b2g/gaia/pull/13043

Great job, as always.
Attachment #821205 - Flags: review?(francisco.jordano) → review+
(In reply to Jose M. Cantera from comment #11)
> Just to note I'm back and could resume the review if you agree

I was out yesterday, so didn't see this till now.  I'm going to go ahead and run with Francisco's r+ unless you have any objections.  Thanks to you both!

Merged:

  https://github.com/mozilla-b2g/gaia/commit/c434b919b2859d0284a935efaf5660b160bdf3b3
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.2 C4(Nov8)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: