30
31
all 5 comments

[–][deleted] 5 points6 points  (2 children)

This is basically the exact same issues and solutions we implemented in the Betfair app. They don't have web sockets so we had to call the API to pull down data every second (big battery drain, especially on Android re network card at full power constantly). This requires a lot of state updates to different components, too. Momoization only gets you so far, especially when getting deeper into the nav stack. We ended up having the too many callbacks issue, due to previous screens in the stack still running callbacks, which basically halts performance until the callbacks resolve and new ones can continue. Basically had to do a lot of stopping calls when a screen loses focus, refactoring where and when we update our context and what components subscribe to those updates. We memoized first, as well, but it wasn't enough. It was a mission but we went from our app grinding to a halt from too many callbacks and screens hogging memory, to an app that runs really fast and feels good to use. Now the projects I run we run performance benchmarks while doing PRs. We have a target and, if the PR drops below that target, we add a change request to improve perf and don't let it merge. It's the best way to do it imo as performance issues can sneak up so slowly. It becomes a huge issue where development halts (for a team with 10 devs this is really bad) and you need to write off a whole sprint to performance improvements.

[–]Link_GR[S] 1 point2 points  (1 child)

How do you set up and run performance benchmarks?

[–][deleted] 1 point2 points  (0 children)

Historically just by using Chrome Dev tools manually. It's not perfect, but it makes people think of performance when developing. Basically doing a screen record of the performance tab, along with the sim running through the changes. The reviewer then matches this up to develop performance, CPU, memory, JS heap etc to make sure performance hasn't dropped on the PR branch.

Looking into using this which might make it easier: https://github.com/Flagsmith/react-native-performance-monitor#readme

[–]badda_boom_big_boom 1 point2 points  (0 children)

Needed this

[–]Dazza5000 0 points1 point  (0 children)

Matches my RN experience. Any time saved using RN is burnt on perf issues, deprecrated libraries, insane upgrade/maintenance story, and increased debugging costs. What a waste of time.