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

TypeError: Cannot read property 'isTypedArray' of undefined, js engine: hermes #8482

Open
kuldip-simform opened this issue Dec 17, 2024 · 0 comments
Labels
type:bug Something isn't working

Comments

@kuldip-simform
Copy link

Hi, I want to perform tensor calculation in my React Native project so I have added this package.
This is my package.json file:

{
  "name": "TFVisionCamera",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^2.1.0",
    "@react-native-masked-view/masked-view": "^0.3.2",
    "@tensorflow/tfjs": "^4.22.0",
    "@tensorflow/tfjs-core": "^4.22.0",
    "@tensorflow/tfjs-react-native": "^1.0.0",
    "expo": "^52.0.0",
    "expo-camera": "^16.0.9",
    "expo-gl": "^15.0.2",
    "expo-modules-core": "^2.1.1",
    "lodash": "^4.17.21",
    "react": "18.3.1",
    "react-native": "0.76.3",
    "react-native-fast-opencv": "^0.3.3",
    "react-native-fast-tflite": "^1.5.0",
    "react-native-fs": "^2.20.0",
    "react-native-reanimated": "^3.16.5",
    "react-native-vision-camera": "^4.6.1",
    "react-native-vision-camera-face-detector": "^1.7.1",
    "react-native-worklets-core": "^1.5.0",
    "vision-camera-resize-plugin": "^3.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@babel/preset-env": "^7.25.3",
    "@babel/runtime": "^7.25.0",
    "@react-native-community/cli": "15.0.1",
    "@react-native-community/cli-platform-android": "15.0.1",
    "@react-native-community/cli-platform-ios": "15.0.1",
    "@react-native/babel-preset": "0.76.3",
    "@react-native/eslint-config": "0.76.3",
    "@react-native/metro-config": "0.76.3",
    "@react-native/typescript-config": "0.76.3",
    "@types/lodash": "^4.17.13",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.3.1",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

This is my App.tsx:

import * as tf from '@tensorflow/tfjs';
import '@tensorflow/tfjs-react-native';
import React, { useCallback, useEffect, useState } from 'react';
import { Button, Text, View } from 'react-native';

const App = () => {
  const [isTfReady, setIsTfReady] = useState(false);
  const loadTFLibrary = useCallback(async () => {
    await tf.ready();
    console.log('Tensorflow is ready');
    setIsTfReady(true);
  }, []);

  useEffect(() => {
    loadTFLibrary();
  }, [loadTFLibrary]);

  const printTensor = () => {
    if (!isTfReady) {
      console.log('Tensorflow is not ready');
      return;
    }

    const ten = tf.zeros([2,2]) // This line works properly
    const tens = tf.tensor1d([2], 'float32'); // getting the error here "TypeError: Cannot read property 'isTypedArray' of undefined, js engine: hermes"
  };

  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>App_Barebone</Text>
      <Button title="Press me" onPress={printTensor} />
    </View>
  );
};

export default App;

When I just run const ten = tf.zeros([2,2]) it runs properly and generates a proper tensor.
Now I want to make my custom tensor from the data I provide with an array. At that time, I am getting the above-mentioned error. I have tried with float32, int32, bool, complex64 and string as well but nothing seems to work.

This is information about my system and which versions I am running for different packages:

System:
  OS: macOS 15.1.1
  CPU: (8) arm64 Apple M1
  Memory: 111.91 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.10.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.18
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.9.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.11.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/kuldip/.rbenv/shims/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:
      - "31"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /Users/kuldip/.sdkman/candidates/java/current/bin/javac
  Ruby:
    version: 3.2.2
    path: /Users/kuldip/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.3
    wanted: 0.76.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: false

I am not sure if I am missing anything or doing anything wrong. Any help will be greatly appreciated

@kuldip-simform kuldip-simform added the type:bug Something isn't working label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant