App crash after execute function isARSupportedOnDevice
Wildanzr opened this issue Β· comments
Requirements:
Please go through this checklist before opening a new issue
- Review the documentation
- Search for existing issues in: ViroCommunity/viro
- Use the latest ViroReact release
Environment
Please provide the following information about your environment:
- Development OS: Windows
- Device OS & Version:
- Android version: 14
- AR Support: YES
- Version:
- ViroReact: ^2.40.1
- React Native: 0.72.6
- Device(s): SM-S908E/DS (Samsung Galaxy S22 Ultra)
Description
Before proceeding to AR Screen, it need to check whether device support AR or not. If supported go to AR Screen, if not show message. However, even the device is supported and successfully go to AR Scene it will be crashed in a seconds. But if there is no execution on function isARSupportedOnDevice
it will not be crashed.
Reproducible Demo
import { isARSupportedOnDevice } from "@viro-community/react-viro";
import { useRouter } from "expo-router";
import React from "react";
import { View, Button } from "react-native";
const TestScreen = (): React.ReactNode => {
const router = useRouter();
const handleGoToARScreen = async (): Promise<void> => {
const result = await isARSupportedOnDevice();
if (result.isARSupported) {
router.push("/ar/");
} else {
console.log("Device not supported");
}
};
return (
<View>
<Button title="Go To AR Screen" onPress={handleGoToARScreen} />
</View>
);
};
export default TestScreen;
import DUCK from "@assets/models/Duck.glb";
import {
Viro3DObject,
ViroAmbientLight,
type ViroTrackingReason,
ViroTrackingStateConstants,
ViroARScene,
} from "@viro-community/react-viro";
import { ViroARSceneNavigator } from "@viro-community/react-viro/dist/components/AR/ViroARSceneNavigator";
import React, { useRef } from "react";
const ARScene = (): JSX.Element => {
const onInitialized = (
state: ViroTrackingStateConstants,
reason: ViroTrackingReason,
): void => {
console.log("guncelleme", state, reason);
if (state === ViroTrackingStateConstants.TRACKING_NORMAL) {
console.log("Tracking normal");
}
if (state === ViroTrackingStateConstants.TRACKING_UNAVAILABLE) {
console.log("Tracking unavailable");
}
};
return (
<ViroARScene onTrackingUpdated={onInitialized}>
<ViroAmbientLight color="#FFFFFF" />
<Viro3DObject
type="GLB"
source={DUCK}
rotation={[0, 0, 0]}
position={[0, 0, -1.15]}
scale={[0.2, 0.2, 0.2]}
style={{ flex: 1 }}
/>
</ViroARScene>
);
};
const AR = (): React.ReactNode => {
const viroNavigatorRef = useRef<ViroARSceneNavigator | null>(null);
return (
<ViroARSceneNavigator
autofocus
ref={(ref) => {
viroNavigatorRef.current = ref;
}}
initialScene={{
scene: ARScene,
}}
videoQuality="High"
style={{ flex: 1 }}
/>
);
};
export default AR;
ah, nevermind this.
The function is working well, my mistake in displaying 3D asset.