ReactVision / viro

ViroReact: The AR and VR library for React Native πŸ“³πŸ’™πŸ’›πŸ€πŸ’š
MIT License
1.41k stars 164 forks source link

IOS App crashes when passing position as props to any Viro component #306

Open alwin12 opened 2 months ago

alwin12 commented 2 months ago

Requirements:

Please go through this checklist before opening a new issue

Environment

  1. Development OS: Macbook air M3, 16 gb ram, macOS Sonoma 14.5
  2. Device OS & Version: iOS version 17.6.1
  3. Version: ViroReact version 2.41.6, react native version 0.74.5
  4. Device(s): Iphone 12 pro max

Description

I'm using ViroARSceneNavigator to render a scene that displays a ViroText component. However, the app crashes when I pass a position prop to ViroText. If I remove the position prop, the app does not crash. I'm running the app on my phone using expo run:ios --device command (Expo SDK 51.0.28).

Things I've tried:

Used a different Viro component, but encountered the same issue. Passed various random Viro3DPoint values to the position prop, but the issue persists.

I've attached a video where you can see the app crashes when I uncomment position={[0, 0, -1]}.

While I have 8 years of experience as a web developer, I'm fairly new to mobile app development. Any help would be greatly appreciated. Thank you!


import {
  ViroARScene,
  ViroARSceneNavigator,
  ViroText,
  ViroTrackingStateConstants,
} from "@reactvision/react-viro";
import React, { useState, useEffect, useRef } from "react";
import { StyleSheet, TouchableOpacity } from "react-native";
import { View, Text } from "react-native";
import * as FileSystem from "expo-file-system"

const HelloWorldSceneAR = () => {
  const [text, setText] = useState("Initializing AR...");
  const [initialized, setInitialized] = useState(false);

  function onInitialized(state, reason) {
    console.log("AR Tracking State:", state, "Reason:", reason);

    if (state === ViroTrackingStateConstants.TRACKING_NORMAL) {
      setInitialized(true);
    } else if (state === ViroTrackingStateConstants.TRACKING_UNAVAILABLE) {
      console.log("tracking unavailable");
    }
  }

  return (
    <ViroARScene onTrackingUpdated={onInitialized}>
      {initialized && (
        <ViroText
          text={text}
          scale={[0.9, 0.9, 0.9]}
          // position={[0, 0, -1]}
          style={styles.helloWorldTextStyle}
        />
      )}
    </ViroARScene>
  );
};

export default () => {
  const arNavigatorRef = useRef(null);

  const captureARSnapshot = async () => {

  // code 

  };

  return (
    <>
      <ViroARSceneNavigator
        ref={arNavigatorRef}
        autofocus={true}
        initialScene={{
          scene: HelloWorldSceneAR,
        }}
        style={styles.f1}
      />

      <View style={styles.bottomView}>
        <TouchableOpacity
          style={styles.captureButton}
          onPress={captureARSnapshot}
        >
          <View style={styles.captureButtonInner} />
        </TouchableOpacity>
      </View>
    </>
  );
};

Reproducible Demo

https://github.com/user-attachments/assets/a1828ce4-abd1-48ae-90ed-f5050d89136a

rozekfr commented 2 months ago

Downgrade to react-native 0.73 or the appropriate version of Expo (I think 50). The module needs to be updated for the latest version of react-native. There is no workaround yet.

alwin12 commented 2 months ago

Downgrade to react-native 0.73 or the appropriate version of Expo (I think 50). The module needs to be updated for the latest version of react-native. There is no workaround yet.

Let me downgrade Expo first and see if that works. Thank you very much ! @rozekfr

alwin12 commented 1 month ago

Downgrade to react-native 0.73 or the appropriate version of Expo (I think 50). The module needs to be updated for the latest version of react-native. There is no workaround yet.

By way of an update, I downgraded the versions and it worked. Thank you @rozekfr

luiscarvalho2000 commented 2 weeks ago

Downgrading is not a possible solution for several reasons.

  1. other libraries need the updated RN.

  2. Due to security issues with previous versions of RN, apps may be rejected from stores.

We need an update on this. As mentioned above, apps may be rejected because of this issue and this possible solution.

HaugaardThomas commented 6 days ago

I downgraded my Expo to 50 and didnt work

HaugaardThomas commented 6 days ago

This is what i currently have and it still crashes with "position" prob

"@reactvision/react-viro": "2.41.6", "expo": "^50.0.21", "react-native": "0.73.6",