react-native-copilot icon indicating copy to clipboard operation
react-native-copilot copied to clipboard

Not support New Arch on react native 0.76

Open nazacity opened this issue 1 year ago • 4 comments

Expected behavior/code It's not scrolled on IOS It's crashed on Android

ERROR Warning: ref.measureLayout must be called with a ref to a native component.

Environment

System:
  OS: macOS 14.7.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 140.69 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.17.1
    path: ~/.nvm/versions/node/v18.17.1/bin/node
  Yarn: Not Found
  npm:
    version: 9.6.7
    path: ~/.nvm/versions/node/v18.17.1/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK:
    API Levels:
      - "23"
      - "27"
      - "29"
      - "30"
      - "31"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-29 | Intel x86 Atom_64
      - android-29 | Google APIs Intel x86 Atom
      - android-30 | ARM 64 v8a
      - android-30 | Google APIs ARM 64 v8a
      - android-30 | Google Play ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-31 | Google Play ARM 64 v8a
      - android-33 | ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-35 | ARM 64 v8a
      - android-35 | Google APIs ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
      - android-VanillaIceCream | Google APIs ARM 64 v8a
      - android-VanillaIceCream | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.15989.150.2411.11948838
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.1.3
    wanted: 15.1.3
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.5
    wanted: ^0.76.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
react-native-copilot: 3.3.3
react-native: 0.76.5
react-native-svg`: 15.10.1

nazacity avatar Nov 14 '24 16:11 nazacity

I couldn't get it to work either, I didn't get any errors during the installation, but there was no change despite triggering it with the start() operation.

System:
  OS: macOS 15.5
  CPU: (14) arm64 Apple M3 Max
  Memory: 327.88 MB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 23.11.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 4.9.1
    path: /usr/local/bin/yarn
  npm:
    version: 10.9.2
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2025.04.14.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/lib/ruby/gems/3.4.0/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK:
    API Levels:
      - "35"
    Build Tools:
      - 35.0.0
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.3 AI-243.26053.27.2432.13536105
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.15
    path: /usr/bin/javac
  Ruby:
    version: 3.4.3
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.3
    wanted: 0.79.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

ertucaglar avatar Jun 21 '25 10:06 ertucaglar

@nazacity Did you manage to fix it?

ArtsiomAstrouski avatar Sep 06 '25 10:09 ArtsiomAstrouski

no hope

nazacity avatar Sep 06 '25 14:09 nazacity

Hi all,

I've implemented a patch that seems to fix the issue described. This solution replaces the use of measureLayout with a more reliable method that uses two separate measure calls to calculate the relative position of the element within the scroll view.

It also includes logic to prevent scrolling if the element is already visible in the top half of the screen and ensures a minimum scroll offset.

I have tested this patch on iOS 26 beta, and it works as expected. However, please note that I have not tested it on Android.

Here is the code I used:

if (scrollView != null && (step === null || step === void 0 ? void 0 : step.wrapperRef.current)) {
  step.wrapperRef.current.measure((_x, _y, _w, h, _pageX, pageY) => {
    scrollView.measure((_sx, _sy, _sw, _sh, _spageX, spageY) => {
      if (pageY >= spageY && pageY < spageY + _sh / 2) {
        return;
      }

      const relativeY = pageY - spageY;
      
      let yOffset = relativeY > 0 ? relativeY - h / 2 : 0;
      
      const MINIMUM_SCROLL_OFFSET = 100;
      yOffset = Math.max(yOffset, MINIMUM_SCROLL_OFFSET);

      scrollView.scrollTo({ y: yOffset, animated: false });
    });
  });
}

P.S. This reply and the code snippet were generated with the assistance of an AI.

PatrickkZhao avatar Sep 15 '25 07:09 PatrickkZhao