viro icon indicating copy to clipboard operation
viro copied to clipboard

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

Open alwin12 opened this issue 1 year ago • 3 comments

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

alwin12 avatar Sep 08 '24 13:09 alwin12

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.

rozekfr avatar Sep 11 '24 15:09 rozekfr

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 avatar Sep 12 '24 11:09 alwin12

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

alwin12 avatar Oct 09 '24 09:10 alwin12

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.

luiscarvalho2000 avatar Nov 07 '24 09:11 luiscarvalho2000

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.

Yep, 100%. The authors of this library need to address this issue. Downgrading RN can't be seen as a solution.

StefanSmudja avatar Dec 17 '24 23:12 StefanSmudja

This should now be resolved in version 2.43.0

Full release notes: https://viro-community.readme.io/changelog/viroreact-2430-whats-new

oliedis avatar Apr 15 '25 10:04 oliedis