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

use one rAF manager #145

Merged
merged 15 commits into from
May 4, 2018
Merged

use one rAF manager #145

merged 15 commits into from
May 4, 2018

Conversation

snewcomer
Copy link
Collaborator

@snewcomer snewcomer commented Apr 27, 2018

Huge thanks to the work done in #103

Also splits out the recursive rAF function to it's own service.

close #103

@snewcomer snewcomer self-assigned this Apr 27, 2018
@snewcomer snewcomer added the WIP label Apr 27, 2018
@snewcomer
Copy link
Collaborator Author

snewcomer commented Apr 27, 2018

@jheth Hey Joe 👋 Would you mind trying out this branch? This uses an rAFPoolManager to use one rAF for all your components on the page. Also, I realized we use a concept called viewportSpy. By default it is false (may change the default in the future). But viewportSpy -

When false, the Mixin will only watch the Component until it enters the viewport once

I short circuited the rAF calls if viewportSpy is kept as the default (false), so rAF will stop running if your component enters the viewport once.

@snewcomer snewcomer removed the WIP label Apr 27, 2018
@jheth
Copy link
Contributor

jheth commented Apr 28, 2018

This looks great! I'll give it a try.

@snewcomer
Copy link
Collaborator Author

@jheth I'll wait for your confirmation before merging 👍

@jheth
Copy link
Contributor

jheth commented May 1, 2018

@snewcomer The branch is much improved over the previous where I was seeing rAF for each LazyImage component I had on the page. However, I'm not seeing the rAF ever stop, even after all images are loaded.

This is a performance chart on page load with 10 lazy image components on the page.
screen shot 2018-05-01 at 6 29 12 pm

This is a close up, showing a single rAF is being used, which is much better than before. 👍
screen shot 2018-05-01 at 6 30 37 pm

This is a performance chart after scrolling to the bottom of the page and all images had been scrolled into the viewport. I don't see a difference from the first chart. I would have expected no more rAF requests.

screen shot 2018-05-01 at 6 35 30 pm

@snewcomer
Copy link
Collaborator Author

@jheth Do you have viewportSpy set to true (ensures continuous rAF calls, default is false)? Here, we are trying to set _stopListening to true.

Here and here.

Let me know what you have set for this property.

@jheth
Copy link
Contributor

jheth commented May 2, 2018

I do not have viewportSpy enabled, it's using the default of false.

@snewcomer
Copy link
Collaborator Author

@jheth I added a test with one slightly small regression. Lmk if you see anything different. Otherwise, perhaps simplify things by putting one image on the page and put a debugger here and ensure _stopListening is true.

@snewcomer
Copy link
Collaborator Author

snewcomer commented May 4, 2018

@jheth Also you can test this behavior (of turning off rAF after first entering the viewport) in the dummy app on the rAF route. I'll merge as is if you don't mind and we can make further improvements in the future.

Thanks again for everything here.

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

Successfully merging this pull request may close these issues.

2 participants