Description
For Discussion
We have a React Native app that renders custom forms fetched from a server. These UIs can be arbitrarily complex, with multiple columns containing potentially many (hundreds) of components, including date-time inputs, images, dropdowns, etc.
For a native version of this app, we would use UICollectionView
on iOS and RecyclerView
on Android. Unfortunately, the current VirtualizedList
implementations in React Native are not conducive to the types of complex layouts we need to render. And the performance when not using a VirtualizedList
can be quite bad, especially on Android which we have measured as taking at least 2x as long to render as iOS.
Possible solutions that we believe would help:
-
A more powerful virtualized container that knows which components should be rendered on the screen and manages the process of fetching and rendering only the necessary views as the user scrolls. Something akin to an iOS
UICollectionView
which treats layout and rendering as separate tasks and keeps a pool of reusable views. Ideally this new virtualized container would be implemented at the native layer and maybe hook into the existingUICollectionView
andRecyclerView
containers provided by iOS and Android. -
We believe that even with the current implementation, performance on Android could be improved with a more efficient interface between the Java and native layers. There is quite a bit of overhead when using JNI and there appear to be many more Java-native calls being made than need to be. The following performance profile shows that iteration calls [1] and array size retrievals [2] were both long-running calls. The latter actually fetches the full array to calculate the size, even though the array itself isn't used. In some cases having it fetch the full array makes sense. However the initial size call shouldn’t need to.