IOS App crashes when passing position as props to any Viro component
Requirements:
Please go through this checklist before opening a new issue
- [x] Review the documentation
- [x] Search for existing issues in: ViroCommunity/viro
- [x] Use the latest ViroReact release
Environment
- Development OS: Macbook air M3, 16 gb ram, macOS Sonoma 14.5
- Device OS & Version: iOS version 17.6.1
- Version: ViroReact version 2.41.6, react native version 0.74.5
- 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
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.
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
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
Downgrading is not a possible solution for several reasons.
-
other libraries need the updated RN.
-
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.
Downgrading is not a possible solution for several reasons.
other libraries need the updated RN.
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.
This should now be resolved in version 2.43.0
Full release notes: https://viro-community.readme.io/changelog/viroreact-2430-whats-new