react-native-fast-image icon indicating copy to clipboard operation
react-native-fast-image copied to clipboard

feat: add Fabric support

Open WoLewicki opened this issue 2 years ago • 33 comments

PR adding New Architecture support to the library :tada:

We at Software Mansion have been working on improving support for the new architecture for quite a while now. If you need help with anything related to New Architecture, like:

or you just want to ask any questions, hit us up on [email protected]


Notes

Some of the code has been provided in https://github.com/DylanVann/react-native-fast-image/pull/933 :tada:

WoLewicki avatar Nov 30 '22 18:11 WoLewicki

@DylanVann i know this library is, in your own words on twitter, "slowly maintained", but could you take a look at this?

andresribeiro avatar Jan 04 '23 13:01 andresribeiro

Hello @DylanVann , may I know if you will consider this PR as one of the support of new architects for this library ? Thanks.

samjayhk avatar Mar 01 '23 14:03 samjayhk

Does anyone know if this PR is still being considered? Working on a project using the new architecture so this would be great for me

norbusonam avatar Apr 24 '23 02:04 norbusonam

I'd love to see this PR upstream if everything works correctly!

canpoyrazoglu avatar May 04 '23 14:05 canpoyrazoglu

While we wait for a response from Dylan, would you be willing to publish this fork as its own package?

Rexogamer avatar May 29 '23 20:05 Rexogamer

What is a benefit of making a fork of this package? You can always install code from a commit. Or am I missing something @Rexogamer ?

WoLewicki avatar May 29 '23 20:05 WoLewicki

Oh, true - I was more suggesting publishing the existing fork as its own package, but installing from a commit should work fine

Rexogamer avatar May 29 '23 20:05 Rexogamer

What are the steps to use this particular commit (which commit?)

tomgreco avatar Jun 24 '23 13:06 tomgreco

@WoLewicki when I updated my package.json to point to your fork I had to patch the package.json to make it work. Without the prepare: npm run build step there was never a dist folder generated.

I'm pretty sure this is a specific issue related to using a github url in a package.json but still worth mentioning.

tomgreco avatar Jun 24 '23 15:06 tomgreco

i added a folder build in the repo and installing like this and it is working but getting this error Error: Unsupported top level event type "topOnFastImageLoadStart" dispatched, js engine: hermes

    "react-native-fast-image": "https://github.com/numandev1/react-native-fast-image#feat/fabric-wolewicki",

numandev1 avatar Jun 28 '23 11:06 numandev1

@numandev1 yes, it is a problem in RN 0.72. I'll push the commits fixing it soon.

WoLewicki avatar Jun 28 '23 12:06 WoLewicki

@WoLewicki thanks a lot for your efforts <3

numandev1 avatar Jun 28 '23 12:06 numandev1

@numandev1 can you check if it works now?

WoLewicki avatar Jun 28 '23 15:06 WoLewicki

@WoLewicki now it is working well, thanks a lot <3

numandev1 avatar Jun 28 '23 19:06 numandev1

Can someone please fork this and maintain it - call it "react-native-fast-image2" ?

billnbell avatar Jul 07 '23 04:07 billnbell

OK for use_framework! this change it needed on RN 0.72.1 for some reason you need to add React-debug and React-utils.

Try this. use_frameworks! :linkage => :static

react-native-fast-image+8.6.3.patch
diff --git a/node_modules/react-native-fast-image/RNFastImage.podspec b/node_modules/react-native-fast-image/RNFastImage.podspec
index 7e50f18..8faf996 100644
--- a/node_modules/react-native-fast-image/RNFastImage.podspec
+++ b/node_modules/react-native-fast-image/RNFastImage.podspec
@@ -27,12 +27,29 @@ Pod::Spec.new do |s|
     s.source_files    = 'ios/**/*.{h,m,mm,cpp}'
 
     s.dependency "React"
+    s.dependency "React-debug"
+    s.dependency "React-utils"
     s.dependency "React-RCTFabric"
     s.dependency "React-Codegen"
     s.dependency "RCT-Folly"
     s.dependency "RCTRequired"
     s.dependency "RCTTypeSafety"
     s.dependency "ReactCommon/turbomodule/core"
+
+    s.subspec "xxxdebug" do |ss|
+      ss.dependency "ReactCommon"
+      ss.dependency "React-debug"
+      ss.source_files         = "react/debug/**/*.{cpp,h}"
+      ss.header_dir           = "react/debug"
+      ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-debug/React_debug.framework/Headers\"" }
+    end
+    s.subspec "xxxutils" do |ss|
+      ss.dependency "ReactCommon"
+      ss.dependency "React-utils"
+      ss.source_files         = "react/utils/**/*.{cpp,h}"
+      ss.header_dir           = "react/utils"
+      ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-utils/React_utils.framework/Headers\"" }
+    end
   else
     s.platforms     = { :ios => "8.0", :tvos => "9.0" }
     s.source_files  = "ios/**/*.{h,mm}"

billnbell avatar Jul 07 '23 05:07 billnbell

@WoLewicki can you maintain this library by forking and pushing with another name on npm? because the owner of this library not having time to see it

numandev1 avatar Jul 07 '23 06:07 numandev1

@numandev1 you can always use expo-image which is compatible with Fabric already.

WoLewicki avatar Jul 07 '23 09:07 WoLewicki

@numandev1 you can always use expo-image which is compatible with Fabric already.

Will this work without using expo?

billnbell avatar Jul 16 '23 02:07 billnbell

@billnbell You only need to install and configure Expo modules with npx install-expo-modules@latest script (follow https://docs.expo.dev/bare/installing-expo-modules/ guide). Once you do that, you can still use RN CLI if that's what you prefer.

tsapeta avatar Jul 17 '23 11:07 tsapeta

@numandev1 you can always use expo-image which is compatible with Fabric already.

so you recommend to use expo-image over this library? does that mean you're gonna abandon this PR for now? I don't like to install expo-modules only if I want to handle Image things.

chj-damon avatar Jul 24 '23 03:07 chj-damon

@WoLewicki It would be nice if you can maintain this as a new package, just like react-native-blob-util which replaces rn-fetch-blob since rn-fetch-blob has not been maintained.

chj-damon avatar Jul 24 '23 03:07 chj-damon

@chj-damon May I ask what's stopping you from installing Expo modules? The impact in binary size is now marginal (and will be even smaller in the next SDK), especially compared to Hermes which surprisingly nobody complains about. Expo modules are also very well maintained by two companies, including us at @software-mansion. They all work with the New Architecture and use JSI even on the old one, making native calls much faster. We also provide some support on the Expo Developers discord in case you have any questions. If you used Expo in the past, I would recommend you to give it another try, a lot have changed.

tsapeta avatar Jul 24 '23 07:07 tsapeta

@tsapeta

  1. expo modules require ios 13 above, which is not ok with my app.
  2. expo will install so many things like expo-asset/ expo-constants/ expo-font etc... which I don't want to use. All I want is a tree, but it gives me a whole forest.
  3. I need to be campatible with some lower react-native versions, like 0.64.x, which it will fails with expo modules.

chj-damon avatar Jul 24 '23 08:07 chj-damon

@chj-damon

  1. React Native 0.73.x will require even 13.4, so I don't think that's a big deal and you should rather drop support for older versions (that's a standard now). iOS below 13.0 is used by less than 1% of active App Store users.
  2. These dependencies are very small and are necessary for many other modules. I'm working on decoupling them, so in SDK 50 they won't be installed.
  3. If you need to be compatible with 0.64.x, then why do you want the FastImage with Fabric support?

tsapeta avatar Jul 24 '23 09:07 tsapeta

@tsapeta thanks for your reply. I'll give it a shot.

chj-damon avatar Jul 24 '23 09:07 chj-damon

@tsapeta hey, I just want to tell you that I've tried expo-image and it works so good! Thank you so much!

chj-damon avatar Jul 25 '23 05:07 chj-damon

i added a folder build in the repo and installing like this and it is working but getting this error Error: Unsupported top level event type "topOnFastImageLoadStart" dispatched, js engine: hermes

    "react-native-fast-image": "https://github.com/numandev1/react-native-fast-image#feat/fabric-wolewicki",

I am getting the same error, I have added "FastImageView" in react-native.config.js, was trying out the New Renderer Interop Layer project: { ios: { unstable_reactLegacyComponentNames:[ "FastImageView", ] }, android: { unstable_reactLegacyComponentNames:[ "FastImageView", ] }, }

ajeetfancode avatar Jul 25 '23 10:07 ajeetfancode

Create a file react-native.config.js

module.exports = {
  project: {
    ios: {
      unstable_reactLegacyComponentNames: [
        'react-native-fast-image',
        'CellContainer',
        'AutoLayoutView',
      ],
    },
    android: {},
  },
  assets: ['./src/assets/fonts'],
};

billnbell avatar Jul 26 '23 05:07 billnbell

@billnbell Isn't we are supposed to give component name instead of the package name in unstable_reactLegacyComponentNames?

ajeetfancode avatar Jul 27 '23 06:07 ajeetfancode