-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Native Fabric (UI-Layer Re-architecture) #4
Comments
Kevin's talk about Fabric internals
Recording - https://www.facebook.com/hramos/videos/10101317533036249/ Video - https://www.slideshare.net/axemclion/react-native-fabric-review20180725 |
We can start a Q&A here where anyone involved can share knowledge and ideas. 😄 I see Fabric as an effort aimed to modernize the rendering layer of React Native. Fabric relies on some new strategies, such as:
Fabric is all about modern, easy-to-interop and performant UI. |
This sounds really cool. :)
Thanks! |
@aleclarson Thank you for your question!
We don't have any public deadline or timeline. It's also hard to define what stable actually means for Facebook and for external users. We have quite ambitious (but realistic) plan to enable Fabric for some of the most popular RN screens in the main app.
Fabric doesn't affect native modules API directly (this is a separate effort), except special kind of NativeModules called ViewManagers. Fabric does not use this approach anymore, any component-specific View Managers have to be rewritten. See also below.
Technically, this problem does not exist in the current architecture, because the shadow tree is not shared between JS and native, each side maintains own copy of the same tree.
They are similar but... totally different. They both connect JS machine with the native world. Bridge is part of React Native.
JSI is not a part of React Native, it's a unified lightweight general purpose API for (theoretically) any JavaScript virtual machine. Now there is only one implementation of that - for JavaScriptCore VM.
In the current architecture, ViewModules almost always contain only props mapping; in Fabric this information is described as
Probably. Probably not. We are thinking that something like this might be valuable and feasible in a couple of years. But, personally, I think if we are thinking about this now, we can figure out something even smarter than that. :) |
Thanks for the Q&A 😃 Will the JNI work like NativeScript does it? I read they don't need bridges written in ObjC/Java. |
Do you mean JSI? I don't know how NativeScript works, so I cannot say. |
Yes, JSI, sorry. AFAIK NativeScript exposes all native APIs in JS, so you don't need to write native code to interact with them. |
@kay-is It is similar, but there are differences. Unlike NativeScript, we would not have a binary file that registers ALL methods on the outset. It is more like HostObjects, which can have getters/setters. |
What side effects can we expect? Decreased build times? Decreased binary sizes? How much of Java/ObjC code will become C++ in the end? |
|
Probably, but that's not our goal. The main goal is to make the code more modern, flexible and maintainable.
The goal is to have as small amount of platform-specific code as possible. It's hard to estimate exact amount though.
At this point, we don't have numbers in which we are confident enough to share. I expect to have them relatively soon though.
(At least on iOS) All native modules which are view managers should be rewritten/adopted to Fabric, eventing else is covered by separated effort called TurboModules. |
|
@axe-fb Do you have any good examples? I've seen expo-gl and just now found |
I'm thinking for react-native-svg the text layout algorithm from the SVG 2.0 spec might make sense to attempt implementing in c++ instead of both obj-c and java. Would be easier to maintain a single implementation. |
Native Animation Driver has to be rewritten, we plan to invest in it this year. Classic
Yes, totally. I think the all non-drawing code should be unified and rewritten in C++. We plan to do this for ART soon. |
I've made an overview talk of how React Native bridge architecture works I've made a talk that presents the current React Native Bridge architecture, explaining its characteristics, how it works and its drawbacks. https://speakerdeck.com/sibelius/react-native-bridges-architectures I think this could be a good intro for the bridge topic |
Are some parts of it already in use without a flag? (on master branch) |
@shergin I’m currently trying to implement the FLIP animation technique in React Native. If you haven’t seen this in browsers, the short version: When the layout of a component changes, we can invert its positional delta via a transform, and then animate it into its new position by animating x and y back to 0 To do this seamlessly, without seeing the component in its new position for a frame, we need to guarantee onLayout is fired before the new position is drawn to the screen. The docs say “the new layout may not yet be reflected on the screen at the time the event is received”, and indeed now and then there is a perceivable “snap”. Will Fabric allow us to guarantee execution of onLayout before the layout is reflected on the screen or am I barking up the wrong tree? Thanks in advance for your input |
A few things:
Hope that helps. |
will this re architecture of react native yield performance as good as flutter or flutter's performance is just hyped about?I have learned react recently and I love it ,will it prove to be a good decision to learn react-native for native mobile apps or in core of your heart you feel flutter is better? |
@contactyash
|
The two main reasons that I stopped using on React Native were Navigation and ListView. |
@joonhocho Yes, Fabric is a foundation that meant to help improve things including navigation (sync external interop) and lists (better/sync measuring API, build-in view recycling and flattening). Fabric itself will not solve that, but it will enable actual solutions. |
@shergin I am wondering, in new react native architecture, whether even the rendering can be synchronized. I believe IOS UITableView requires synchronized rendering of cells. That means React should render and return native cell view to the tableview in synchronized way. Will this kind of behavior supported by the new architecture or rendering will be always asynchronous? |
@terrysahaidak for android they are using or simple you can enable fabric in android by |
Is there a config option in file to enable fabric for iOS? Thanks |
@bijiabo you can pass
then you need to install pod again |
navigate to Codegen package and remove it's lib/dist. run yarn build. then reinstall pods (remove Pods and Podfile.lock) |
I don’t think this actually enables Fabric. It just enables some libraries to be included in the build |
Yep, such as React-Fabric, it used to add FBReactNativeSpec but now it's part of the default setup (because RN uses Codegen now for internal stuff). In order to render you app with Fabric, you need to use FabricSurface as a RootView. Here you can find the diff how to enable it on RN 0.65 |
Is there any performance data between the Fabric renderer and the original one? Such as TTI, memory, FPS, etc. We used RN heavily in our products. Just want to evaluate the benefit of upgrading to the latest RN with the Fabric renderer. @shergin |
@bojie-liu Fabric renderer might not impact the TTI directly but it might have some effect on memory and FPS, to improve the TTI we need to wait for TurboModules and other stuff to land which will have bigger impact. It would be good if we can have some numbers for all of the new architecture components individually and overall to see the difference. |
With the new architecture, I understand developing modules & components will need static types & a matching codegen (e.g. Flow/TypeScript). Am I right in thinking that for regular app code, we can still use untyped JS, or languages with a JS backend like ClojureScript? |
@simon-nicholls library authors should provide these types in order to generate binding on build time. for app developers it's not required. you can continue using any language which compiles into js. you can even develop the module itself in js. just the TurboModule interface should be defined in TS/flow. |
@terrysahaidak Great, thanks. Makes perfect sense. |
@kelset any updates on the release? |
No updates on the rollout of Fabric at this point in time. We are still working on RN67 and dealing with an issue with Hermes 0.10 |
@Standard-Tech at ReactConf, the Facebook team said that they are planning to release the new architecture "next year" (2022). Nothing more precise than that for now, sorry |
Slightly disappointed, I had expected the new architecture to be released this year |
FYI, Fabric is for the most part already there in the OSS repo, but it lacks documentation. The core team is working on an extensive document for library authors to adopt it. You can trace it here: facebook/react-native-website#2879 :) |
Quick heads-up, a first version of the documentation describing the new architecture (Fabric's side) is now live in the documentation at the url: https://reactnative.dev/docs/fabric-renderer (link also added to top post) |
What would be the base version to test with the above changes? @terrysahaidak RN 0.65 works for android as well? |
What is the official view on this, if this is really the case, it would be too disappointing, after all, waiting for such a long time, we really hope that the new architecture can make the performance of react native on the next level, especially the performance of FlatList. |
@gaodeng Fabric is so much more than just a "faster FlatList". Fabric (and JSI) provides so many possibilities that simply would've never been possible with the current architecture. You need to keep in mind that a React Native app on Fabric improves in lots of areas, such as uniform cross-platform code, better performance in initial renders, re-renders, and concurrent rendering. We at Margelo are working on building a JSI list component that uses a different foundation than FlatList, and we are expecting it to be faster than FlatList and RecyclerListViewer, even on Fabric and all without providing an item layout function. This would not be possible without Fabric. |
@mrousavy that is all fine you folks at Margelo can create separate package for list management, I guess vast majority of people using RN will use the builtin FlatList, I believe this is still worth investigating what is the cause of high cpu usage. |
Hi All, I am so excited about new react-native architecture. But i am wondering how it work?
|
Hey, you can find everything at new architecture documentation, but basically:
|
Hi @lukebars I mean from the Native part, with current native Views: Text, ScrollView... It will be replaced by new Views written by Objective-C++, C++? Because when i compiled the RN-Tester app with fabric ENABLED. I saw the view is not working normally. Example fontVariant: small-caps not working. BUT it works with fabric DISABLED. I guess meta teams is re-writting views by C++. Do you know the document to write a native component like that? |
hey folks, since we have now an official deep dive discussion open on this in the ReactWG New architecture, let's close this one and make the conversation progress over there: reactwg/react-native-new-architecture#1 Remember that you can apply to the WG (in case you are not in it yet) by applying to the form in the readme. |
Intro
With this issue I'd like to try and create a "one stop" for all the information available around the future re-architecture of the UI-Layer of React Native, codenamed "Fabric".
Terminology
TL;DR
From @axe-fb's blogpost, here's a temporary description of Fabric (please consider that this is not yet finalized, it may change in the future)
Available Materials
It was first announced in the "State of React Native 2018" blogpost by @sophiebits.
In July, @hramos linked a broadcast of a tech talk that happened in FB, which covered the ongoing work on the new React Native architecture codenamed "Fabric": facebook.com/hramos/videos/10101317533036249 (go to 8:18 for the presentation start - audio is a bit bad)
Further down the line, it was presented at ChainReact Conf 2018 by @axe-fb in the talk "The State of React Native".
At ReactConf 2018 @axe-fb did a talk about React Native's New Architecture, which also explains the 3 concepts above: JSI, Fabric, TurboModule.
On twitter, @shergin shared a presentation about View Flattening -> https://twitter.com/shergin/status/1058393187079704576?s=09
On twitter, @kmagiera shown a early stage implementation of Fabric working on the RNTester app -> https://twitter.com/kzzzf/status/1064891715457294337
IN Q1 2019, @kelset published a high-level/beginner friendly blogpost about it: https://formidable.com/blog/2019/fabric-turbomodules-part-3/ and did a talk about the whole rearchitecture in April 2019 at React Edinburgh.
@kelset also did a more in-depth talk at React Advanced London in Oct 2019: youtube recording & slides.
As of early Jan 2022, a first version of the docs about Fabric are on the main reactnative.dev website.
SWM published a blogpost on how they added Fabric to one of their libraries: https://blog.swmansion.com/introducing-fabric-to-react-native-screens-fd17bf18858e
Q&A
This is also a place for questions related to this effort and its direction.
The text was updated successfully, but these errors were encountered: