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

Android ViroARTrackingTargets.createTargets crash #245

Open
utiq opened this issue Jan 18, 2024 · 2 comments
Open

Android ViroARTrackingTargets.createTargets crash #245

utiq opened this issue Jan 18, 2024 · 2 comments
Labels
Android Affects google devices running Android

Comments

@utiq
Copy link

utiq commented Jan 18, 2024

I'm attempting to develop a basic AR app with a target, but it crashes on Android in this section ViroARTrackingTargets.createTargets, while it works fine on iOS.
Instead of cloning the Viro template, I integrated the library directly into my existing app.
When I remove the ViroARTrackingTargets.createTargets section; and I program a simple 'Hello World' message in the scene, it works fine, it doesn't crash.

When the crash occurs, there is no React log whatsoever. Therefore, I resorted to using logcat to obtain some potentially useful information. I hope this helps in diagnosing the issue.

Development OS: MacOS M3, Sonoma 14.2.1
react: "18.2.0",
react-native: "0.73.2",
@viro-community/react-viro: "^2.23.0"
Device: Samsung S20+, Android 13

Here there are the logcat logs

01-17 21:58:36.885  5788  5788 I com.my-app: Late-enabling -Xcheck:jni
01-17 21:58:36.898  5788  5788 I com.my-app: Using CollectorTypeCC GC.
01-17 21:58:37.267  5788  5788 W com.my-app: Accessing hidden field Landroid/view/View;->mKeyedTags:Landroid/util/SparseArray; (unsupported, reflection, allowed)
01-17 21:58:37.267  5788  5788 W com.my-app: Accessing hidden field Landroid/view/View;->mListenerInfo:Landroid/view/View$ListenerInfo; (unsupported, reflection, allowed)
01-17 21:58:37.267  5788  5788 W com.my-app: Accessing hidden field Landroid/view/View$ListenerInfo;->mOnClickListener:Landroid/view/View$OnClickListener; (unsupported, reflection, allowed)
01-17 21:58:37.322  5788  5788 W com.my-app: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
01-17 21:58:37.322  5788  5788 W com.my-app: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
01-17 21:58:38.191  5788  5882 W com.my-app: Accessing hidden field Ljava/lang/reflect/Field;->accessFlags:I (unsupported, reflection, allowed)
01-17 21:58:38.224  5788  5882 W com.my-app: Entry not found
01-17 21:58:38.731  5788  5880 I ReactNativeJS: 'dimensions.height', 779.3777777777777
01-17 21:58:38.984  5788  5880 I ReactNativeJS: Running "my-app" with {"rootTag":21}
01-17 21:58:39.292  5788  5880 W com.my-app: CheckJNI: method to register "installJSIBindings" not in the given class. This is slow, consider changing your RegisterNatives calls.
01-17 22:00:31.624  6004  6004 I com.my-app: Late-enabling -Xcheck:jni
01-17 22:00:31.638  6004  6004 I com.my-app: Using CollectorTypeCC GC.
01-17 22:00:32.011  6004  6004 W com.my-app: Accessing hidden field Landroid/view/View;->mKeyedTags:Landroid/util/SparseArray; (unsupported, reflection, allowed)
01-17 22:00:32.011  6004  6004 W com.my-app: Accessing hidden field Landroid/view/View;->mListenerInfo:Landroid/view/View$ListenerInfo; (unsupported, reflection, allowed)
01-17 22:00:32.011  6004  6004 W com.my-app: Accessing hidden field Landroid/view/View$ListenerInfo;->mOnClickListener:Landroid/view/View$OnClickListener; (unsupported, reflection, allowed)
01-17 22:00:32.066  6004  6004 W com.my-app: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
01-17 22:00:32.066  6004  6004 W com.my-app: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
01-17 22:00:32.934  6004  6096 W com.my-app: Accessing hidden field Ljava/lang/reflect/Field;->accessFlags:I (unsupported, reflection, allowed)
01-17 22:00:32.965  6004  6096 W com.my-app: Entry not found
01-17 22:00:33.470  6004  6095 I ReactNativeJS: 'dimensions.height', 779.3777777777777
01-17 22:00:33.723  6004  6095 I ReactNativeJS: Running "my-app" with {"rootTag":21}
01-17 22:00:34.027  6004  6095 W com.my-app: CheckJNI: method to register "installJSIBindings" not in the given class. This is slow, consider changing your RegisterNatives calls.
01-17 22:00:34.160  6004  6095 I ReactNativeJS: 'RESOURCES', undefined
01-17 22:00:34.418  6004  6095 W ReactNativeJS: [ReferenceError: Property 'resultSource' doesn't exist], '\n    at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:253836:26)\n    at StaticContainer (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:180083:17)\n    at EnsureSingleNavigator (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:175884:24)\n    at SceneView (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:179988:22)\n    at RCTView\n    at View (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:60060:43)\n    at RCTView\n    at View (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:60060:43)\n    at Background (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:181732:21)\n    at Screen (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:182751:108)\n    at RNSScreen\n    at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:76073:62)\n    at Suspender (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:192737:22)\n    at Suspense\n    at Freeze (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:192756:23)\n    at DelayedFreeze (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:191933:22)\n    at InnerScreen (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:191982:36)\n    at Screen (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:192258:36)\n    at MaybeScreen (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:191810:24)\n    at RNSScreenContainer\n    at ScreenContainer (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:192114:31)\n    at MaybeScreenContainer (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:191799:23)\n    at RCTView\n    at View (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:60060:43)\n    at RCTView\n    at View (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:60060:43)\n    at AnimatedComponent(View) (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:147914:38)\n    at RCTView\n    at View (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:60060:43)\n    at AnimatedComponent(View) (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:147914:38)\n    at PanGestureHandler (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.my-app&modulesOnly=false&runModule=true:183
01-17 22:00:34.476  6004  6004 D com.my-app: PlayerBase::PlayerBase()
01-17 22:00:34.476  6004  6004 D com.my-app: TrackPlayerBase::TrackPlayerBase()
01-17 22:00:34.650  6004  6004 W com.my-app: Accessing hidden field Landroid/widget/ScrollView;->mScroller:Landroid/widget/OverScroller; (unsupported, reflection, allowed)
01-17 22:00:34.674  6004  6004 I ReactNative: [GESTURE HANDLER] Initialize gesture handler for root view com.facebook.react.ReactRootView{fb06053 V.E...... ......ID 0,0-1080,2192 #15}
01-17 22:00:34.743  6004  6136 D com.my-app: PlayerBase::stop() from IPlayer
01-17 22:00:35.011  6004  6004 W com.my-app: Loading /data/app/~~P-6H3B2yWnQ8LIGF6ty6tw==/com.google.ar.core-Jw0JKuyZliOxH8XROqsBNw==/oat/arm64/base.odex non-executable as it requires an image which we failed to load
01-17 22:00:35.014  6004  6004 W com.my-app: Entry not found
01-17 22:00:35.016  6004  6004 W com.my-app: Entry not found
01-17 22:00:35.655  6004  6145 D com.my-app: PlayerBase::stop() from IPlayer
01-17 22:00:36.390  6004  6004 D com.my-app: PlayerBase::stop() from IPlayer

Here there is the code I'm using:

import React, {useState, useEffect} from 'react';
import {StyleSheet, PermissionsAndroid} from 'react-native';
import {
  ViroARScene,
  ViroTrackingStateConstants,
  ViroARSceneNavigator,
  ViroAmbientLight,
  Viro3DObject,
  ViroARTrackingTargets,
  ViroARImageMarker
} from '@viro-community/react-viro';

const HelloWorldSceneAR = () => {
  const [text, setText] = useState('Initializing AR...');

  return (
    <ViroARScene>
      <ViroAmbientLight color="#ffffff" />
      <ViroARImageMarker target="pug2D_img">
        <Viro3DObject
          source={require('../../res/test/untitled.vrx')}
          position={[0, 0, 0]}
          scale={[0.0001, 0.0001, 0.0001]}
          rotation={[0, 0, 0]}
          type="VRX"
          dragType="FixedToWorld"
          onDrag={() => {}}
        />
      </ViroARImageMarker>
    </ViroARScene>
  );
};

export default () => {
  return (
    <ViroARSceneNavigator
      autofocus={true}
      initialScene={{
        scene: HelloWorldSceneAR,
      }}
      style={styles.f1}
    />
  );
};

var styles = StyleSheet.create({
  f1: {flex: 1},
  helloWorldTextStyle: {
    fontFamily: 'Arial',
    fontSize: 30,
    color: '#ffffff',
    textAlignVertical: 'center',
    textAlign: 'center',
  },
});

ViroARTrackingTargets.createTargets({
  pug2D_img: {
    source: require('../../res/reference.jpg'),
    orientation: 'Up',
    physicalWidth: 0.15
  },
});
@robertjcolley robertjcolley added the Android Affects google devices running Android label Jan 29, 2024
@agallardoysla
Copy link

@robertjcolley we was talking in other PR, this is exactly my problem I think.

@robertjcolley
Copy link
Collaborator

@robertjcolley we was talking in other PR, this is exactly my problem I think.

Sounds good! Thank you for updating this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Affects google devices running Android
Projects
None yet
Development

No branches or pull requests

3 participants