Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Performance on mobile #49

Open
tusharmath opened this issue May 28, 2016 · 9 comments
Open

Performance on mobile #49

tusharmath opened this issue May 28, 2016 · 9 comments

Comments

@tusharmath
Copy link

I have a one plus one running chrome on android. I tried the side nav example on it and have attached the timeline data below. I am not able to achieve anywhere close to 60fps and that's because of the expensive VDOM diffs being done on every touchmove event.

ReactSideNavPerf.json.zip

This one, which doesn't use lib, turns out to be much faster — https://googlechrome.github.io/ui-element-samples/side-nav/

@woogenius
Copy link

@tusharmath I think you can disable touch behavior for now. I turned off as well.

@tusharmath
Copy link
Author

@woogenius I don't think that's a solution.

@balloob
Copy link
Owner

balloob commented Jul 28, 2016

Yeah, we should debounce the onTouchMove calls to not clog up the paint queue. Pull request welcome.

@tonygentilcore
Copy link

In addition to debouncing, it would be nice if touch events could all be made passive:
https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md

@balloob
Copy link
Owner

balloob commented Oct 26, 2016

Good point. To use passive listeners, we would have to attach our DOM Event listeners ourselves using a ref-callback instead of having React attach them.

@tonygentilcore
Copy link

Yeah, facebook/react#6436 :/

@Ayc0
Copy link

Ayc0 commented Dec 1, 2017

you can fasten the module without using the passive listeners : your main issue comes from React itself:

Currently, when onTouchMove is triggered, you reset the state with new values of touchCurrentX and touchCurrentY. So the all lifecycle of a component is triggered

What you should do is set a ref to the sidebar and directly set the style by doing something like:
this.sidebar.setAttribute('style', fromObjectToCSS(sidebarStyle)) (but you'll need to call this function manually and not rely on the rerender of the component)

@Ayc0
Copy link

Ayc0 commented Dec 1, 2017

and also, you should throttle the touchMove function

@timbset
Copy link

timbset commented Feb 8, 2018

Hey, guys. I have a solution that is high-performance enaugh - https://github.com/timbset/react-advanced

@markusenglund markusenglund mentioned this issue Jul 30, 2018
4 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants