Skip to content
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

Support for New Architecture - iOS & Android (Fabric) #931

Closed
wants to merge 42 commits into from

Conversation

markrickert
Copy link
Contributor

@markrickert markrickert commented Oct 10, 2023

Description

Fixes #196, #811, & #886

This PR builds on @j-piasecki's work in #550 to enable Fabric/New Architecture. That PR is fairly old and was created with react-native@0.70.4 (lots of performance issues) and FlashList@1.2.1.

Here's what I did to bring things back up to date so that people can start testing this with the latest version of FlashList:

  1. Got @j-piasecki's fabricfixture app building properly.
  2. Rebased this fabric branch with @shopify/flash-list@master to bring the library up to the latest version (1.6.2)
  3. Upgraded the fabricfixture app from react-native@0.70.4 to 0.72.5 ensuring that both iOS and android fixture apps built and displayed the FlashList component with the new architecture turned on.

Things I did NOT do:

  • I did not touch or edit ANY of the fabric code that @j-piasecki wrote. All credit goes to him.

Things I think we still need to do:

  • Investigate using react-native-test-app so we don't have to have two fixture apps in the repo anymore (one for new architecture and another for old architecture). This will get rid of a lot of duplicated code as suggested by @fortmarek here Fabric support now uses the main fixture app.
  • Ensure that nothing broke in the non-fabric renderer.
  • Test the he🏒🏒 out of this.

Reviewers’ hat-rack 🎩

  • Check the instructions in the readme for how to test the fixture app in both old and new architecture..

Screenshots or videos (if needed)

These videos are from the app built by the react native app in ./fabricfixture. Get ready to have a seizure, lol.

iOS Android
4361F280-4566-4146-9C74-5EF53CDABF67-76478-0001A1F3D40DDEDD 6E27994A-9439-4D04-95F5-B3531068FE01-5137-00028CE649BCEF28

Checklist

@markrickert
Copy link
Contributor Author

I have signed the CLA!

@RichardLindhout
Copy link

LGTM!

@markrickert
Copy link
Contributor Author

Thanks for testing this out @RichardLindhout! Did you run across any issues? Any ideas on how we could combine the two fixture apps into a single app that could test both the old and new architecture?

@RichardLindhout
Copy link

I did not test it, I just was hoping FlashList would get Fabric support :). I'm not experienced with Fabric so I'm not sure.

@naqvitalha
Copy link
Collaborator

Apologies for the delay, I'll try this out soon. Thanks a lot

@T-Damer
Copy link

T-Damer commented Nov 12, 2023

Let's goooo

Copy link

@WoLewicki WoLewicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@chakravarthi-bb
Copy link

Can we release this??

@evelant
Copy link

evelant commented Dec 14, 2023

This is the last dependency our app preventing it from working with the new arch. Hopefully this can get released soon!

@evelant
Copy link

evelant commented Dec 14, 2023

@markrickert I tried your fork in my app and it seems to work perfectly with the new architecture enabled!

@markrickert
Copy link
Contributor Author

I rebased my work here on main.

@WoLewicki
Copy link

@markrickert could you maybe bump the version of fabric app to RN 0.73 to see if it works?

@markrickert
Copy link
Contributor Author

@markrickert could you maybe bump the version of fabric app to RN 0.73 to see if it works?

That's a great idea. I'll work on that here in the next few days

@BLOCKMATERIAL
Copy link

up please very important

@JJSLIoT
Copy link

JJSLIoT commented Jan 1, 2024

Can we get this lint check passed to unblock the PR from being approved?

@renopp
Copy link

renopp commented Jan 8, 2024

Tested at RN 0.73.1 android and running well ❤️

fabricfixture/.eslintrc.js Outdated Show resolved Hide resolved
Copy link

@WoLewicki WoLewicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add those changes so it works correctly on new arch in the newest version of RN and also makes it possible to use it from this commit?

RNFlashList.podspec Outdated Show resolved Hide resolved
RNFlashList.podspec Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
@markrickert
Copy link
Contributor Author

This PR should be ready to go. I've updated the PR based on suggestions as well as ensured that both the fixture app and fabricfixture app build and run on the latest Mac OS (14.3) and the latest Xcode (15.2)

CI is finally passing all green ✅ and I rebased on main and force-pushed (sorry to anyone using my branch commit hashes directly in their project).

The fabricfixture app has been updated to react-native 0.72.10 for now.

Copy link

@WoLewicki WoLewicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments for now. Please answer them.

RNFlashList.podspec Outdated Show resolved Hide resolved
android/build.gradle Outdated Show resolved Hide resolved
return cellContainer
} else if subview is AutoLayoutView {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe we should make the AutoLayoutView not collapsable to avoid it?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WoLewicki @markrickert just wanted to check: apart from this comment are there any other issues with this PR which is blocking the merge?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it looks ok

@@ -3,7 +3,7 @@ import Foundation
@objc(CellContainerManager)
class CellContainerManager: RCTViewManager {
override func view() -> UIView! {
return CellContainer()
return CellContainerComponentView()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it work if there is no implementation of this class on paper? Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, this would be a question for @j-piasecki since he made all the changes to the native source code. I didn't delve into exactly how that all works, but both fixture apps are running so maybe some magic codegen going on here? I'm not as well versed in new arch native changes as I'd like to be right now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I contacted him and I get it now. You can see such code at the end of CellContainerComponentView:

@implementation CellContainerComponentView
@end

so it resolves to simple UIView there 😅

@j-piasecki j-piasecki mentioned this pull request Feb 7, 2024
1 task
@markrickert
Copy link
Contributor Author

Rebased on main and fixed the merge conflicts.

@ChronoByteCosmonaut
Copy link

Is this going to be merged soon? 🤔

Copy link

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this, @markrickert! (And @j-piasecki too!)

Copy link

@T-Damer T-Damer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Copy link

@anton-patrushev anton-patrushev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

qq: is it compatible with latest 74 RN release?

@ChronoByteCosmonaut
Copy link

What’s the status on this one?

@gorbypark
Copy link

gorbypark commented Apr 28, 2024

Great job!

qq: is it compatible with latest 74 RN release?

Just a very quick test, but I spun up a new Expo 51 project (which is RN 0.74.0) and this pr seems to work great on both iOS/Android with new arch bridgless mode enabled.

# create a new project with SDK51 (as of April 28, 2024 this is the beta version)
yarn create expo-app --template default@beta

# this just removes the examples in the app folder
yarn reset-project

# required to enable new architecture
npx expo install expo-build-properties

# use flashlist from this PR
yarn add https://github.com/markrickert/flash-list.git\#mrickert/fabric

# generate android and ios folders
npx expo prebuild --clean

app.json (enable new architecture)

    "plugins": [
      "expo-router",
      [
        "expo-build-properties",
        {
          "ios": {
            "newArchEnabled": true
          },
          "android": {
            "newArchEnabled": true
          }
        }
      ]
    ],

/app/index.tsx

import React from "react";
import { Text } from "react-native";
import { FlashList } from "@shopify/flash-list";

const DATA = [
{
 title: "First Item",
},
{
 title: "Second Item",
},
];

export default function App() {
return (
 <FlashList
   data={DATA}
   renderItem={({ item }) => <Text>{item.title}</Text>}
   estimatedItemSize={200}
 />
);
}

Build and run app

yarn ios
yarn android

A very simple usage of flashlist (copied directly from the flashlist doc site) but both platforms are working as expected. There seems to be some issue with types when installing from the GitHub repo instead of NPM, but I'm going to assume that will sort itself out if this is merged into main.
Screenshot 2024-04-28 at 12 26 22 PM

@almoatamed
Copy link

this is very important, is this going to be merged?

@almoatamed
Copy link

@WoLewicki please your review

@WoLewicki
Copy link

I am not a maintainer of this library unfortunately.

@saxenanickk
Copy link

@naqvitalha @jenshenny Anyone maintaining this library?

@jfmoe
Copy link

jfmoe commented May 21, 2024

Any progress?

@naqvitalha
Copy link
Collaborator

We've started looking at this PR. I'll update soon. Thanks @markrickert @j-piasecki

@@ -4,31 +4,33 @@ import UIKit

/// Container for all RecyclerListView children. This will automatically remove all gaps and overlaps for GridLayouts with flexible spans.
/// Note: This cannot work for masonry layouts i.e, pinterest like layout
@objc class AutoLayoutView: UIView {
@objc public class AutoLayoutView: UIView {
@objc public var onBlankAreaEventHandler: ((CGFloat, CGFloat) -> Void)?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markrickert While testing I noticed that onBlankArea event isn't working. On Android, the name of the event was emitBlankAreaEvent instead of onBlankAreaEvent so I fixed it. It also isn't working on iOS, I'm not sure if this is the right way to handle it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naqvitalha did you maybe check if it fails to enter this part of code: https://github.com/Shopify/flash-list/pull/931/files#diff-5fac05017cc8297ba991cb968f2703854339d60ae995e08e9cfe66545186f745R46 ? It is the place where the event should be sent to JS.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the RCT_NEW_ARCH_ENABLED preprocessor directive isn't working as expected. @j-piasecki Can you check?

@Jackmekiss
Copy link

Let's merge it guys!

s.source = { git: 'https://github.com/shopify/flash-list.git', tag: "v#{s.version}" }
s.source_files = 'ios/Sources/**/*'
s.requires_arc = true
s.swift_version = '5.0'

# Dependencies
s.dependency 'React-Core'
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naqvitalha The RCT_NEW_ARCH_ENABLED isn't actually set anywhere.

Suggested change
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
if fabric_enabled
s.pod_target_xcconfig = {
'OTHER_SWIFT_FLAGS' => '-D RCT_NEW_ARCH_ENABLED',
}
end
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.

And then it would also be required to check if the flag is set at the top level (cannot add suggestion there 😞):

fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED']

@markrickert
Copy link
Contributor Author

Closing because #550 was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore Fabric support