Closed Bug 942460 Opened 11 years ago Closed 11 years ago

[Contacts] Implement position:sticky for fixed headers

Categories

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

ARM
Gonk (Firefox OS)
defect

Tracking

(blocking-b2g:1.3+, b2g-v1.3 fixed, b2g-v1.3T fixed, b2g-v1.4 fixed)

RESOLVED FIXED
1.4 S1 (14feb)
blocking-b2g 1.3+
Tracking Status
b2g-v1.3 --- fixed
b2g-v1.3T --- fixed
b2g-v1.4 --- fixed

People

(Reporter: bkelly, Assigned: kgrandon)

References

Details

(Keywords: perf, Whiteboard: [c=handeye p=4 s= u=1.3] [ETA:waiting_for_review])

Attachments

(2 files, 3 obsolete files)

In order to improve our scroll performance we should pursue replacing our FixedHeader javascript code with the position:sticky CSS attribute.

Currently position:sticky is disabled behind the layout.css.sticky.enabled preference.  This seems to be due to both some crashes and uncertainty about a specification for the new attribute value.
Attached file Proof-of-concept (obsolete) —
This is an incomplete proof-of-concept that we can use to investigate and profile any performance benefits.
Whiteboard: [c= p= s= u=] → [c=handeye p= s= u=]
Attached file Pull request - remove fixed headers (obsolete) —
I had this patch sitting around for a long time, so placing it here in case we want to use it.
Vivien - I think you may have been interested in this. One of the two patches here may help you test stuff :)
Flags: needinfo?(21)
(In reply to Kevin Grandon :kgrandon from comment #3)
> Vivien - I think you may have been interested in this. One of the two
> patches here may help you test stuff :)

It seems to perform well with APZ. Nice.
Blocks: 943849
Flags: needinfo?(21)
Blocks: 945472
No longer blocks: 945472
Already blocks 943849, so cleaning up the dependency chain.
No longer depends on: 916315
Updated the pull request to port the import list headers over to position: sticky as well.
Attachment #8341223 - Attachment is obsolete: true
Assignee: nobody → kgrandon
Status: NEW → ASSIGNED
Comment on attachment 8337275 [details] [review]
Proof-of-concept

Obsoleting PoC from Ben.
Attachment #8337275 - Attachment is obsolete: true
Whiteboard: [c=handeye p= s= u=] → [c=handeye p=2 s= u=]
Depends on: 945777
Summary: consider using position:sticky in contacts app → [Contacts] Implement position:sticky for fixed headers
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

Ben - Wondering if you would like to use your contact peer powers to review this one. Let me know if you don't have the cycles or would like another peer to review it.
Attachment #8341369 - Flags: review?(bkelly)
I can review, but why did you drop the dependency on bug 916315?  There are a bunch of crasher sub-dependencies there we probably need to address before moving forward.
To be more clear, at this point I would r- the patch because it appears position:sticky is not ready for prime time.
(In reply to Ben Kelly [:bkelly] from comment #9)
> I can review, but why did you drop the dependency on bug 916315?  There are
> a bunch of crasher sub-dependencies there we probably need to address before
> moving forward.

We've added a dependency on bug 945777 for gaia. We may end up enabling it in gaia earlier than in release Firefox, and potentially only doing so for certified apps.

(In reply to Ben Kelly [:bkelly] from comment #10)
> To be more clear, at this point I would r- the patch because it appears
> position:sticky is not ready for prime time.

We want to review these patches now, but not land them until we turn on position: sticky in gaia. As soon as it is enabled, we want to be able to quickly land these patches.

Most crashes and issues are being resolved in parallel, and after looking at them, they are not things that certified apps will run into.
Hmm, I guess I'm a little uncomfortable giving r+ and having the patch sit while master changes underneath it.  How about I give feedback now and I promise to give a quick review when we are closer to landing?

Also, I just put in the overflow:hidden to improve our scroll performance as it greatly reduced the reflows due to modifying the DOM as we scroll.  I'm worried about regressing there.
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

(In reply to Ben Kelly [:bkelly] from comment #12)
> Hmm, I guess I'm a little uncomfortable giving r+ and having the patch sit
> while master changes underneath it.  How about I give feedback now and I
> promise to give a quick review when we are closer to landing?

I will try to clarify timelines, but the goal was to have these patches reviewed and ready to go. I am fine with feedback for now though, so that will work. Thanks!
Attachment #8341369 - Flags: review?(bkelly) → feedback?(bkelly)
I'll review this tomorrow.  I tried it on the phone, though, and it appears to work.  I saw a visual defect (bug 946516), but it looks like that is in master.
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

As I said, I plan to review this today, but it would also be good to get feedback from Francisco and Jose Manuel.
Attachment #8341369 - Flags: review?(bkelly)
Attachment #8341369 - Flags: feedback?(jmcf)
Attachment #8341369 - Flags: feedback?(francisco.jordano)
Attachment #8341369 - Flags: feedback?(bkelly)
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

The code looks good, but I think there are a couple visual and performance issues to solve before landing this.

1) When using the jump letters on the side of the list to scroll up you will see two headers at the top of the screen.  Scroll to the bottom and then run your finger up the jump bar on the right to see this effect.

2) We are reflowing a lot more when scrolling the list with this patch.  I believe this is probably due to removing the overflow:hidden attribute.

Profile before patch:

http://people.mozilla.org/~bgirard/cleopatra/#report=1031859c979d1053d283749879aaf5c2b2e6a8d7

Profile after patch:

http://people.mozilla.org/~bgirard/cleopatra/#report=b3c711c06147653e9197426396d1f684d5469c58

Search for Flush or Flush_Int in these profiles.  You will see that there are more reflows and they are longer now.  I think this is going to drop our fps values.

Finally, it seems there have been some style changes recently in master.  Can you rebase this to the most recent version?

Overall I agree this is where we want to go in the future, I just want to make sure we don't regress getting there.  Thanks!
Attachment #8341369 - Flags: review?(bkelly) → review-
Upping the points here since solving the perf issue here may be more involved.
Whiteboard: [c=handeye p=2 s= u=] → [c=handeye p=4 s= u=]
Thanks for the in-depth work here Ben. We've received R+ for the other apps, but I will run the same profiling tests there as well to make sure we don't regress.
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

Hi Ben,

Thanks for taking a look. I've rebased the Pull Request and have ran profiles for the branch and master. Here are the profiles now:

Master branch: http://people.mozilla.org/~bgirard/cleopatra/#report=3cc8b031b848ba8dd78aa9f2db5ff3148f68c43e

Position Sticky Branch: http://people.mozilla.org/~bgirard/cleopatra/#report=0ee70bae23bc865fce28824ed7d934d4fcd2fa10

I'm seeing that the two profiles are fairly similar now. I'm thinking this could possibly be related to the new will-animate property which has landed in contacts (not sure if you were testing that, but our profiles look vastly different).

Can you take a look at these profiles to see if you can spot any obvious differences? Thanks!
Attachment #8341369 - Flags: review-
Flags: needinfo?(bkelly)
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

From a functional perspective I'm ok with the patch, but leave final decision on landing to Ben as he is the expert on perf issues and I wouldn't like to regress.

Nonetheless, it is great to see Gecko supporting position: sticky as it saves many JS lines to maintain!
Attachment #8341369 - Flags: feedback?(jmcf) → feedback+
Kevin, can you tell me more about how you took the profile?

Here is what I did for the profiles in comment 16:

1) Install reference-workload-medium
2) Open contacts and wait for images to show signifying workload is fully loaded.
3) Start profiling using this command:

./profile.sh start -p b2g -f js,stackwalk && ./profile.sh start -p Communications -f js,stackwalk -e 500000

4) Scroll down 3 or 4 flicks to about the J group.
5) ./profile.sh capture

I think perhaps you are missing most of the scroll in your profile because you don't have the -e 500000 in your profile start command.
Flags: needinfo?(bkelly) → needinfo?(kgrandon)
That's true, I don't have the -e argument, but the rest of my test is mostly the same. I'll change up the arguments and try capturing the profile again. Thanks!
Flags: needinfo?(kgrandon)
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

Codewise looking good, thanks Kevin and sorry for the delay!
Attachment #8341369 - Flags: feedback?(francisco.jordano) → feedback+
Kevin can you rebased an asked for r? I'm going to push for sticky in 1.4.
(In reply to Vivien Nicolas (:vingtetun) (:21) from comment #24)
> Kevin can you rebased an asked for r? I'm going to push for sticky in 1.4.

Originally I thought that for this one to land, we would need to solve bug 915302. This was due to the overflow: hidden not working with position: sticky. This may no longer be the case with APZ, and we will likely need to profile to determine this. I'll set aside some time to profile with APZ this week.
I'm currently looking at some of the other issues in comment 16, but for the time being here are profiles with and without position sticky.

Position Sticky: http://people.mozilla.org/~bgirard/cleopatra/#report=71960e538be1d03709203f4966f0542c547cd44b
Master: http://people.mozilla.org/~bgirard/cleopatra/#report=6a544a71d5ad2d48b38d04dfbe05b98163054604
Ok, here's a few new profiles. I wanted to compare with and without overflow: hidden against position: sticky to see how they would do with APZ. Some interesting things in the profiles. 

When filtering by `flush`:
Without overflow, and position sticky, the most time is spent in: nsBlockFrame::FrameStartsCounterScope(nsIFrame*)
With overflow hidden, this changes to be: nsCSSOffsetState::InitOffsets(int, int, nsIAtom*, nsMargin const*, nsMargin const*)

When not filtering, the "Most time spent in" is the same across all three profiles. I'm going to dig into these profiles a bit more in the next few days to see if I can notice any differences. For on device testing, we've been seeing better performance with position: sticky than with FixedHeader.js - I think this is due to slow scroll updates from APZ though.

Master No Overflow: http://people.mozilla.org/~bgirard/cleopatra/#report=010ed31d2795983020db0247330b2d64c909d3aa
Master /w Overflow: http://people.mozilla.org/~bgirard/cleopatra/#report=a268f86436a3135c8e71ad744863cb7091407d3c
Position Sticky: http://people.mozilla.org/~bgirard/cleopatra/#report=d7cfe211d2e9246e001eb779f2b06c210f4837ef
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

Ben - Comment 27 has some new profiles for this. At this point I'm not really sure if we have an option here as APZ is now turned on, and there are definitely scrolling problems with FixedHeaders now. (You see them jump occasionally on a hamachi). I've tried looking into the headers and testing this manually, and I could not really detect a regression here.

Please let me know what you think when you have a chance to look at this.
Attachment #8341369 - Flags: review?(bkelly)
Adding a dependency on bug 945472 as this will solve the travis issue. (I didn't want two commits in here, and will not land until the tree is green). Sorry about the confusion!
Depends on: 945472
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

A few minor nits in the pull request, but otherwise the code itself looks good.

Unfortunately, though, there are a few visual defects:

1) The header underline extends too far to the left.
2) The row highlight wraps around the header when you select a contact.

I'll post some screenshots with these.

Because of the visual defects I need to r-.
Attachment #8341369 - Flags: review?(bkelly) → review-
Attachment #8369525 - Attachment is obsolete: true
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

Hi Ben,

It turns out we were using building blocks incorrectly. I've fixed the styling so everything should be well now. I updated the PR and made the following changes:

1 - Fixed underline so it matches each item's underline as in master.
2 - Fixed highlight to only highlight until the underline does (as in building blocks).

Please review when you have a chance, thanks!
Attachment #8341369 - Flags: review- → review?(bkelly)
Hmm, I think Jose specifically modified the highlight to go all the way across previously.  Jose, do you recall?
Flags: needinfo?(jmcf)
Seems incorrect to me, but we can check with some of the visual designers: http://buildingfirefoxos.com/building-blocks/lists.html
I would recommend nothing is landed before Arnau, our CSS expert, reviews this. Asking a review to Arnau

thanks
Flags: needinfo?(jmcf)
Attachment #8341369 - Flags: review?(arnau)
(In reply to Kevin Grandon :kgrandon from comment #27)
> Master No Overflow:
> http://people.mozilla.org/~bgirard/cleopatra/
> #report=010ed31d2795983020db0247330b2d64c909d3aa
> Master /w Overflow:
> http://people.mozilla.org/~bgirard/cleopatra/
> #report=a268f86436a3135c8e71ad744863cb7091407d3c
> Position Sticky:
> http://people.mozilla.org/~bgirard/cleopatra/
> #report=d7cfe211d2e9246e001eb779f2b06c210f4837ef

I think you meant to profile the compositor thread here. Keep the same command for the App you're profiling but watch the b2g compositor using:
./profile.ps start -p b2g -t Compositor.
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

r=me assuming Arnau signs off on the list selection highlight.

Right now it appears that FixedHeader does a better job of keeping the header at the top of the page, but overall I know we will have better performance with position:sticky.  We should land this and do further work on APZ/position:sticky to address any issues with the header not sticking to the top in a timely manner.
Attachment #8341369 - Flags: review?(bkelly) → review+
Sorry I've been busy with the visual refresh, I'll try to check that ASAP.
1.3+, blocks existing blocker Bug 967277.

Kevin, please update the whiteboard ETA field.
Priority: -- → P1
Whiteboard: [c=handeye p=4 s= u=] → [c=handeye p=4 s= u=1.3] [ETA:?]
Target Milestone: --- → 1.4 S1 (14feb)
blocking-b2g: --- → 1.3+
Whiteboard: [c=handeye p=4 s= u=1.3] [ETA:?] → [c=handeye p=4 s= u=1.3] [ETA:waiting_for_review]
Looks r+'ed.  What else are we waiting for here?
(In reply to Chris Lee [:clee] from comment #41)
> Looks r+'ed.  What else are we waiting for here?

We are just waiting on a R? from Arnau here I think.
(Specifically for CSS/style changes)
Comment on attachment 8341369 [details] [review]
Pull request - Use position:sticky for fixed headers

Sorry again for the delay. Works awesome!
There's one pixel where you can see the content, between the sticky header and the main header.
But don't worry I could fix this in my next patch for contacts.
Thanks Kevin, nice work.
Attachment #8341369 - Flags: review?(arnau) → review+
I was not able to uplift this bug to v1.3.  If this bug has dependencies which are not marked in this bug, please comment on this bug.  If this bug depends on patches that aren't approved for v1.3, we need to re-evaluate the approval.  Otherwise, if this is just a merge conflict, you might be able to resolve it with:

  git checkout v1.3
  git cherry-pick -x -m1 b8e6475fc45395580dd17e8b5d44c65f1b6f6045
  <RESOLVE MERGE CONFLICTS>
  git commit
Flags: needinfo?(kgrandon)
Blocks: 967292
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: