Skip to content

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

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

Closed
3 tasks done
alwin12 opened this issue Sep 8, 2024 · 6 comments
Closed
3 tasks done

Comments

@alwin12
Copy link

alwin12 commented Sep 8, 2024

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

RecordIt-1725800142.MP4
@alwin12 alwin12 changed the title App crashes when passing position as props to any Viro component IOS App crashes when passing position as props to any Viro component Sep 8, 2024
@rozekfr
Copy link

rozekfr commented Sep 11, 2024

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
Copy link
Author

alwin12 commented Sep 12, 2024

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
Copy link
Author

alwin12 commented Oct 9, 2024

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
Copy link

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.

@StefanSmudja
Copy link

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.

@oliedis
Copy link
Contributor

oliedis commented Apr 15, 2025

This should now be resolved in version 2.43.0

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

@oliedis oliedis closed this as completed Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants