Live data from Hacker News

Tempted to Abandon React Native for Native Android

kelvinpompey.me

61–63 of 63 posts

Re: Tempted to Abandon React Native for Native Android

#61
post #58
post #17

Earlier quoted context omitted.

I analysed react-native's performance issues with images and out-of-memory-errors a while back. Their (and their image library Fresco's) problem is that they make heavy use of object-finalizers, which is an error in Java and especially Android. I reported a couple of bugs, but got dismissed: https://github.com/facebook/react-native/issues/8711 https://github.com/facebook/react-native/issues/8780 https://github.com/fa…

Hey, RN Android dev here: re: object finalizers: - For Fresco, I think Balazs provided a pretty good response here on how Fresco uses the finalizers ( https://github.com/facebook/react-native/issues/8711#issueco... ). If you still think there's an issue here, I'll direct Balazs to this post. - For RN, I remember the issue you cited stated that using Object.finalize is 430x slower than having no finalizer, which sound…

Hi, astreet, thanks so much for taking your time,

I want to stress again that finalizers complicate and slows code in very complex ways. Just measuring the startup time isn't enough. You essentially slow down the garbage collector by giving him work and code he can't analyse or optimise.

The mere usage of finalizers, even if they log only, can lead to Out-Of-Memory-errors when there's still memory available!

This user showed that the numbers of waiting finalizers went up to a couple of thousand after they switching to Fresco: https://github.com/facebook/fresco/issues/1363#issuecomment-...

Think about it: 5000 finalizers waiting to be run! The finalizer-queue is single-threaded, which means that every other object on the same ART that has a finalizer will have to wait until these 5000 finalizers are through, before they can be garbage collected.

No need to apologize though, I know that RN is being flooded with attention and changing core code is not trivial.

Again, thank you for your time.

Re: Tempted to Abandon React Native for Native Android

#62
post #61
post #58

Earlier quoted context omitted.

Hey, RN Android dev here: re: object finalizers: - For Fresco, I think Balazs provided a pretty good response here on how Fresco uses the finalizers ( https://github.com/facebook/react-native/issues/8711#issueco... ). If you still think there's an issue here, I'll direct Balazs to this post. - For RN, I remember the issue you cited stated that using Object.finalize is 430x slower than having no finalizer, which sound…

Hi, astreet, thanks so much for taking your time, I want to stress again that finalizers complicate and slows code in very complex ways. Just measuring the startup time isn't enough. You essentially slow down the garbage collector by giving him work and code he can't analyse or optimise. The mere usage of finalizers, even if they log only, can lead to Out-Of-Memory-errors when there's still memory available! This use…

I see, if we're talking about apps somehow accumulating thousands of finalizer references, something seems very wrong, as we're talking about 10's of ms of work. I'm not sure how many references we typically hit in our apps, but I'm pushing the fresco team to A/B test with removing finalizers to actually see what impact we see in our apps: it'd be a good data point to have internally and externally about using finalizers. That being said, we're hoping to update the OSS RN version of fbjni which uses a PhantomReference queue, and Fresco has also been considering a PhantomReference queue. I'll try to keep you updated on the fresco task.

Re: Tempted to Abandon React Native for Native Android

#63
post #62
post #61

Earlier quoted context omitted.

Hi, astreet, thanks so much for taking your time, I want to stress again that finalizers complicate and slows code in very complex ways. Just measuring the startup time isn't enough. You essentially slow down the garbage collector by giving him work and code he can't analyse or optimise. The mere usage of finalizers, even if they log only, can lead to Out-Of-Memory-errors when there's still memory available! This use…

I see, if we're talking about apps somehow accumulating thousands of finalizer references, something seems very wrong, as we're talking about 10's of ms of work. I'm not sure how many references we typically hit in our apps, but I'm pushing the fresco team to A/B test with removing finalizers to actually see what impact we see in our apps: it'd be a good data point to have internally and externally about using finali…

Splendid news, thank you.
Post reply on HN