ARActivity crashes on destroy with java.lang.NullPointerException for void com.google.vrtoolkit.cardboard.sensors.HeadTracker.stopTracking()

kudanar
ar-android
kudan

#1

I have a simple setup with two activities ActivityA extends android.app.Activity and ActivityB extends eu.kudan.kudan.ARActivity.

ActivityA has only one button to start ActivityB with
Intent intent = new Intent(getApplicationContext(), ActivityB.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(intent);.

Unfortunately ActivityB is not destroyed properly and crashes sometimes during back press with:
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.vrtoolkit.cardboard.sensors.HeadTracker.stopTracking()' on a null object reference

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.vrtoolkit.cardboard.sensors.HeadTracker.stopTracking()' on a null object reference
at eu.kudan.kudan.ARGyroManager.deinitialise(ARGyroManager.java:71)
at eu.kudan.kudan.ARFragment.onDestroy(ARFragment.java:128)
at android.app.Fragment.performDestroy(Fragment.java:2586)

This makes it unusable to extract ARActivity to a separate activity.
@LukeKudan any workarounds, hotfixes, etc.?