Skip to content
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

Crash on simulator, any workaround? #310

Open
3 tasks done
tedcu opened this issue Oct 23, 2024 · 3 comments
Open
3 tasks done

Crash on simulator, any workaround? #310

tedcu opened this issue Oct 23, 2024 · 3 comments

Comments

@tedcu
Copy link

tedcu commented Oct 23, 2024

Requirements:

Environment

Mac, iOS 17.2, iPhone 15 Pro simulator

"@reactvision/react-viro": "^2.41.6",
"react-native": "0.73.5",

Bare react native project, non-expo.

Description

Simulator crashes immediately on startup, even without using any viro-react features. I was looking through some previous issues where this is mentioned, but I don't think any of them were actually solved, just closed.

I don't need AR features on a simulator, but it would be nice to run e2e and develop features that are not related to AR on a sim. So, any workarounds? Real device works, of course, but we need simulator to at least not crash.

Trace snippet:

Termination Reason: DYLD 1 Library missing
Library not loaded: @rpath/GTMSessionFetcher.framework/GTMSessionFetcher
Referenced from: <5D09F0A1-93BE-31F2-B28B-565B1A89B535> /Users/me/Library/Developer/CoreSimulator/Devices/91AD94B5-3753-4246-AD68-2962FF689C49/data/Containers/Bundle/Application/5CB74D3C-B33B-45EA-ACEE-E1BD134056F1/Marketplace.app/Frameworks/ViroKit.framework/ViroKit
Reason: tried: '/Users/me/Library/Developer/CoreSimulator/Devices/91AD94B5-3753-4246-AD68-2962FF689C49/data/Containers/Bundle/Application/5CB74D3C-B33B-45EA-ACEE-E1BD134056F1/Marketplace.app/Frameworks/GTMSessionFetcher.framework/GTMSessionFetcher' (no such file), '/Users/me/Library/Developer/CoreSimulator/Devices/91AD94B5-3753-4246-AD68-2962FF689C49/data/Containers/Bundle/Application/5CB74D3C-B33B-45EA-ACEE-E1BD134056F1/Marketplace.app/Frameworks/ViroKit.framework/Frameworks/GTMSessionFetcher.framework/GTMSessionFetcher' (no such file), '/Users/me/Library/Developer/CoreSimulator/Devices/91AD94B5-3753-4246-AD68-2962FF689C49/data/Container
(terminated at launch; ignore backtrace)
@jefersonjuliani
Copy link

you must run on a physical device, Apple Simulator and Android Emulator don´t acess ARCore (Android) and ARKit (iOS).

@jirka-oone
Copy link

jirka-oone commented Nov 23, 2024

It's not an ideal solution but we solved it by adding this condition to the Podfile

if !ENV["EXCLUDE_VIRO"]
 puts "adding VIRO.."
 pod 'ViroReact', :path => '../node_modules/@reactvision/react-viro/ios'
 pod 'ViroKit', :path => '../node_modules/@reactvision/react-viro/ios/dist/ViroRenderer/'
else
 puts "removing VIRO.."
end

in package.json then someting like this

"prepare:simulator": "EXCLUDE_VIRO=true; yarn install"

@haakonjacobsen
Copy link

haakonjacobsen commented Dec 21, 2024

I solved this a bit hacky by adding a config I called USE_VIRO as an environment variable, and then dynamically import Viro based on the config.

In My ARScreen:

let Viro3DObject: any,
  ViroAmbientLight: any,
  ViroARPlaneSelector: any,
  ViroARScene: any,
  ViroARSceneNavigator: any,
  ViroMaterials: any,
  ViroTrackingStateConstants: any;

if (config.USE_VIRO) {
  Viro3DObject = require('@reactvision/react-viro').Viro3DObject;
  ViroAmbientLight = require('@reactvision/react-viro').ViroAmbientLight;
  ViroARPlaneSelector = require('@reactvision/react-viro').ViroARPlaneSelector;
  ViroARScene = require('@reactvision/react-viro').ViroARScene;
  ViroARSceneNavigator = require('@reactvision/react-viro').ViroARSceneNavigator;
  ViroMaterials = require('@reactvision/react-viro').ViroMaterials;
  ViroTrackingStateConstants = require('@reactvision/react-viro').ViroTrackingStateConstants;
}

export default function ArScreen({ route, navigation }: ArScreenProps) {

  if (!config.USE_VIRO) {
    return (
      <View style={styles.placeholderView}>
        <Text style={textStyles.h4}>AR is disabled in this build</Text>
      </View>
    );
  }
  
  return (
      <ViroARScene
        onTrackingUpdated={handleTrackingUpdated}
        onAnchorUpdated={(_anchor: any) => setAnchorFound(true)}
      >
        <ViroAmbientLight color={'#ffffff'} />
        <ViroARPlaneSelector>
          // other viro stuff
        </ViroARPlaneSelector>
      </ViroARScene>
    );
  };
// 

Setup some way of getting the USE_VIRO config.

export const config = {
  USE_VIRO: !(process.env.USE_VIRO === 'false')
};

Adding the USE_VIRO env to the scripts:

{
  "scripts": {
    "start:dev": "USE_VIRO=true npx expo start --dev-client -c",
    "start:dev-simulator": "USE_VIRO=false npx expo start --dev-client -c",
    "build:ios-simulator": "USE_VIRO=false eas build --profile development-simulator --platform ios --local",
    "build:ios-dev": "USE_VIRO=true eas build --profile development --platform ios --local",
    "build:android-simulator": "USE_VIRO=false eas build --profile development --platform android --local",
    "build:android-dev": "USE_VIRO=true eas build --profile development --platform android --local",
  },
}

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

4 participants