Replies: 8 comments
-
Much of this is also an opportunity for unification of a bunch of code. Many of these problems are currently solved by platform specific implementations. Android has a bunch of java classes that perform much the same need as these. And iOS has a bunch of objective C classes that do the same. To solve these problems in react-native-windows we had to write a new implementation in C++ as the Java and ObjC code is platform specific. We are working on making the react-native-windows implementation completely platform agnostic C++. With the idea that it can be shared cross platform. And eventually become part of the shared cxxcommon code in react-native. Hopefully this becomes the basis of the next version of react-native instance management infra. This will allow more code sharing between the platforms -- which should mean all the platforms get better tested, and more consistent in behavior with each other, and reduce total cost of new features. |
Beta Was this translation helpful? Give feedback.
-
@stmoy Thanks for writing this up! Like @acoates-ms said I think some of the issues you described are solved by platform-specific implementations, but some of them aren't really solved at all - we have issues with instance management and destruction on Android, for example, that we don't have a great solution for right now. So I'm definitely interested in seeing how we can incorporate some of what Microsoft has learned working on RNW into RN core (in particular, into the new "bridgeless" core that we're currently working on). Here are a few of the areas for discussion I'd like to explore:
I also have some more in-the-weeds questions about the code, but these are the major discussion topics I thought of. |
Beta Was this translation helpful? Give feedback.
-
@ejanzer, just a few thoughts about your bullet points above:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! Threading model: I like the promises/futures model, and this is actually pretty similar to what I'm doing right now for bridgeless RN on Android (although I'm doing it in Java using Bolts-Tasks right now). We're not planning on making any significant changes to the RN threading model right now - I just wanted to clarify that you weren't doing anything different in your code that we'd have to reconcile. |
Beta Was this translation helpful? Give feedback.
-
@vmoroz @stmoy I created a proposal for the runtime creation & management discussion, if you want to take a look: #196 |
Beta Was this translation helpful? Give feedback.
-
Thank you, Steven, for putting this together! That looks great indeed, I love the idea of unifying the concepts among platforms... and moving everything that possible to C++ (even if something can be done in C++ on more than one platforms, that might sense to do it for that platforms on C++). One of the explicit goals that we have with Fabric (and in general with Venice) is to end up with as little platform-specific code as possible. Surely it will be practically impossible to make this shift in one step even if we unconditionally agree on everything beforehand, so I think we need to figure out some gradual path forward. I think we should agree on concepts, then on naming, and then start to implement pieces and connect them together. React Native is a quite huge framework, so huge that I don't think we have a single person who has a strong opinion about every single aspect of the framework, so we have to design it as a set of relatively independent units. E.g. I have a lot to say about the proper UI layer (esp. on iOS) but I have limited knowledge about non-UI modules or constrains. Even "simple" things like The good thing is that we are already doing that with Venice and Fabric, and from what I see mostly aligned with our design ideas. From the UI/iOS perspective, I think Fabric is quite aligned with the proposed UI (green) part of the schema: In short, I am saying, let's:
|
Beta Was this translation helpful? Give feedback.
-
Hi Valentin, these are good points! The terms above is something that we used in Office when we worked on implementing ReactNative. The code in that PR is just an initial merge. We must do several iterations to clean it up, rename namespaces and types, and remove a lot of unnecessary layers.
The key difference between Host and Instance in this implementation is that Host is a very small object that can exists as long as needed. It can load and unload Instance that is quite expensive because of JavaScript engine. There may be no difference for apps that are completely RN-based, but for apps like Microsoft Word where RN is only used for some UI parts, it can be important because the Host objects allow us to free memory when no RN-UI is shown. Each Host may have several ViewHosts. It means that the same ReactInstance can use several windows or panels. For example, in Outlook, we can show several popups for personal info about different people using the same ReactInstance. |
Beta Was this translation helpful? Give feedback.
-
Introduction
The existing React Native implementation (on Windows) for host and instance management infrastructure suffers from a variety of issues, including:
The goal/purpose of this proposal is to provide a framework-grade implementation for React Native for Windows. Longer term, this model can be adapted for the React Native core platform across iOS/Android as well.
The Core of It
High-level design:
There are two main object types that are going to be in the ReactNativeHost:
The IReactHost holds one ReactInstance.
ReloadInstance
,DestroyInstance
, etc.The IReactViewHost is associated with a corresponding platform specific ReactRootView component.
ReactInstance
ReactApplication
Discussion points
Beta Was this translation helpful? Give feedback.
All reactions