EddyVerbruggen / nativescript-ar

Augmented Reality NativeScript plugin
https://www.nativescript.org/blog/preview-of-augmented-reality-in-nativescript
MIT License
118 stars 36 forks source link

Android crash on back navigation while HandMotionAnimation is visible #95

Open nickolanack opened 4 years ago

nickolanack commented 4 years ago

seems to consistently crash on a back navigation while the hand motion animation (detect a plane) is visible. this is not an issue for FaceDetection, or ImageDetection modes

System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getWidth()' on a null object reference
System.err:     at com.google.ar.sceneform.ux.HandMotionAnimation.applyTransformation(HandMotionAnimation.java:48)

Android Pixel2 (Android 10)

nickolanack commented 4 years ago

I fixed the issue in my application by adding following snippet. (added in my app on page events)

beforeDisposeNativeViewNavigation(){
    //let _fragment=ar.getFragment();
    _fragment.getPlaneDiscoveryController().hide();
    _fragment.getPlaneDiscoveryController().setInstructionView(null);
}

I'm not sure exactly how this would be added to ar.android.ts - it needs to be executed before the page transition occurs (disposeNativeView happens after navigation )