facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.51k stars 604 forks source link

Support FinalizationRegistry in Hermes #1440

Open cyrillicw opened 2 weeks ago

cyrillicw commented 2 weeks ago

Problem

Is FinalizationRegistry support planned to be added to Hermes? It would be convenient to have finalizers for managing native resources in React Native, and is supported by most of modern JS engines

tmikov commented 2 weeks ago

It is blocked on React Native implementing an event loop that calls drainMicrotasks(). Similarly, Hermes has had an implementation of WeakRef for years, but to this day it can't be used for the same reason.

The RN folks are working on a new event loop. Once that lands and become standards, we can implement FinalizationRegistry.

cyrillicw commented 2 weeks ago

@tmikov Thank you for your answer! According to this issue https://github.com/facebook/react-native/issues/42742 they are going to support the new event loop and WeakRefs in the next React Native version 0.75. Can we expect that after that FinalizationRegistry might be implemented?