ARCore Session causes Sensor.TYPE_ACCELEROMETER SensorEvent values to be invalid (axes are swapped). This occurs randomly, around 50% of the times.
VERSIONS USED
Android Studio: Android Studio Flamingo | 2022.2.1 Patch 1
ARCore SDK for Android: 1.39.0
Device manufacturer, model, and O/S: Samsung Galaxy S22 Ultra (SM-S908B/DS)
Google Play Services for AR (ARCore): 1.41.233110993
STEPS TO REPRODUCE THE ISSUE
I created an example app to test this issue, see: https://github.com/henrikyn/ARCoreAndAccelerometer/tree/master.
In the application's first activity there's a switch "Start with ARCore", and two buttons "Start in Portrait" and "Start in Landscape".
With the switch you can set if you want to start the second activity with ARCore Session or not, and the two buttons start the second activity in either portrait/landscape. The second activity will always start listening for accelerometer data, and print the data on a TextView.
When the "Start with ARCore" switch is checked, the accelerometer data will be invalid (axes swapped) around 50% of the times, in both landscape and portrait. When it is not checked, the accelerometer data is always valid (axes are not swapped).
ADDITIONAL COMMENTS
Did some quick tests, where I started the second activity with different settings and checked if the accelerometer data is valid or not, here's the results:
Portrait, without ARCore:
50/50 valid accelerometer data.
Landscape, without ARCore:
50/50 valid accelerometer data.
Portrait, with ARCore:
4/10 valid accelerometer data.
Landscape, with ARCore:
6/10 valid accelerometer data.
SPECIFIC ISSUE ENCOUNTERED
ARCore Session causes Sensor.TYPE_ACCELEROMETER SensorEvent values to be invalid (axes are swapped). This occurs randomly, around 50% of the times.
VERSIONS USED
STEPS TO REPRODUCE THE ISSUE
I created an example app to test this issue, see: https://github.com/henrikyn/ARCoreAndAccelerometer/tree/master. In the application's first activity there's a switch "Start with ARCore", and two buttons "Start in Portrait" and "Start in Landscape". With the switch you can set if you want to start the second activity with ARCore Session or not, and the two buttons start the second activity in either portrait/landscape. The second activity will always start listening for accelerometer data, and print the data on a TextView. When the "Start with ARCore" switch is checked, the accelerometer data will be invalid (axes swapped) around 50% of the times, in both landscape and portrait. When it is not checked, the accelerometer data is always valid (axes are not swapped).
ADDITIONAL COMMENTS
Did some quick tests, where I started the second activity with different settings and checked if the accelerometer data is valid or not, here's the results:
Portrait, without ARCore: 50/50 valid accelerometer data.
Landscape, without ARCore: 50/50 valid accelerometer data.
Portrait, with ARCore: 4/10 valid accelerometer data.
Landscape, with ARCore: 6/10 valid accelerometer data.