google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.95k stars 1.22k forks source link

ARCore Session causes Sensor.TYPE_ACCELEROMETER SensorEvent values to be invalid (axes are swapped) #1629

Open henrikyn opened 9 months ago

henrikyn commented 9 months ago

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.