News for hackers. Stuff that matters.
Re:How Discord achieves native iOS performance with React Na... by londons_explore on Friday November 08, 2019 @04:52AM (#21481014)
A spinner running in the background consuming CPU is two bugs...

The non-obvious one is why is the framework consuming any CPU time at all on something not visible? When an element tries to animate, and the whole element is covered/offscreen, the framework should simply pause the animation. When the element becomes visible again, it's simple to calculate how long the element has been invisible, and fast-forward the animation to that frame.

Re:How Discord achieves native iOS performance with React Na... by ericlewis on Friday November 08, 2019 @08:20AM (#21481907)
I’ve seen this happen especially with Lottie. And what basically happens here is the actual drawing isn’t actually handled by react-native since the library is itself a native view to either platform. Therefore, react-native has no idea it’s wasting any resources because it’s not technically “in charge” of what exactly the native view itself is doing. It certain scenarios where it might be “covered up”, such as all JavaScript based views (which are essentially just UIViews in iOS) then iOS itself also doesn’t know to stop this animation either (view compositing is quite popular).

However, if using something like native navigation, where view controllers and their life cycle get handled by iOS then it will correctly end an animation.

I have no idea if this is true for Android. But I have witnessed it on iOS and fixed this issue in react-native apps on quite a few occasions.

The ultimate downside to frameworks like this is they imo, don’t know enough about the content they’re showing to make great choices for users. But at the same time, it’s not fully desirable to attempt to assume. That’s the platforms job. And that’s an obvious catch-22. How should you know this if you aren’t a native app builder?

Re:How Discord achieves native iOS performance with React Na... by mrkcsc on Friday November 08, 2019 @12:48PM (#21484779)
The strongest RN teams and engineers I've seen tend to be those that either already have or are willing to acquire knowledge about how native app development works under the hood.

It greatly augments your ability to write elegant solutions to hard problems.

Some argue this is a large cost to bear - however I'd say it's one that is very reasonable to acquire. Having experience and knowledge in several languages/frameworks helps make one stronger engineer.

Re:How Discord achieves native iOS performance with React Na... by obmelvin on Friday November 08, 2019 @10:37AM (#21483139)
> How should you know this if you aren’t a native app builder?

My impression has been that to use RN well you need to mostly think like and have the knowledge of someone who is a native app developer. You just get some benefit of sharing UI across platforms, but still need to do many things you would for native.

I haven't used RN, just saw my friend who uses give a talk on it. So I certainly may not understand exactly how much native code you can or can't write while also using RN.

Re:How Discord achieves native iOS performance with React Na... by dep_b on Friday November 08, 2019 @05:23AM (#21481101)
If a UITableView is not visible it doesn't render anything at all. Which is a real gotcha if you didn't know that through a UI bug your height got set to 0 ;)
Re:How Discord achieves native iOS performance with React Na... by reimertz on Friday November 08, 2019 @07:12AM (#21481541)
Maybe you created your own spinner, swapping between 100 cute pngs...?
Re:How Discord achieves native iOS performance with React Na... by tinus_hn on Friday November 08, 2019 @08:36AM (#21482010)
On Mac OS iTunes and Finder manage to waste a lot of CPU spinning spinners while running g their backups. Apparently either it isn’t that easy or it’s easy to do wrong.