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

"Sensor orientation is not available" for some Android devices #452

Open
ttrvdw opened this issue Aug 10, 2023 · 4 comments
Open

"Sensor orientation is not available" for some Android devices #452

ttrvdw opened this issue Aug 10, 2023 · 4 comments

Comments

@ttrvdw
Copy link

ttrvdw commented Aug 10, 2023

Describe the bug
Orientation is not available for devices that do not have some sensors. e.g. a device with only accelerometer will return "Sensor orientation is not available" error when subscribing to "orientation".

Tested setup:
Samsung Galaxy A04s with accelerometer but no gyroscope or magnetometer.
Working without error on Samsung Galaxy S8 and iPhone XR.

To Reproduce
Steps to reproduce the behavior:

Take phone with accelerometer but no gyroscope nor magnetometer (e.g. Samsung A20).

import {
  orientation,
  SensorTypes,
  setUpdateIntervalForType,
} from 'react-native-sensors';

const subscription = orientation.subscribe(data => {...})

This will return
Sensor orientation is not available

Expected behavior
The package should check what sensors are available to make the orientation measurements. I suspect that some sensor fusion is happening under the surface, but the module should check internally what sensors are available for the fusion. In case of single sensor, an orientation estimate, be it noisy, should still be returned. It's up to the end user to decide how to deal with noisy sensor data.

Desktop

  • React Native Version: 0.71.7
  • Device: Samsung Galaxy A04s, physical device
  • Version: Android 13
@ernesdev
Copy link

I had to solve it in the native Android module, that is the patch that worked for me using the accelerometer sensor.
@ttrvdw
react-native-sensors+7.3.6.patch

Describe the bug Orientation is not available for devices that do not have some sensors. e.g. a device with only accelerometer will return "Sensor orientation is not available" error when subscribing to "orientation".

Tested setup: Samsung Galaxy A04s with accelerometer but no gyroscope or magnetometer. Working without error on Samsung Galaxy S8 and iPhone XR.

To Reproduce Steps to reproduce the behavior:

Take phone with accelerometer but no gyroscope nor magnetometer (e.g. Samsung A20).

import {
  orientation,
  SensorTypes,
  setUpdateIntervalForType,
} from 'react-native-sensors';

const subscription = orientation.subscribe(data => {...})

This will return Sensor orientation is not available

Expected behavior The package should check what sensors are available to make the orientation measurements. I suspect that some sensor fusion is happening under the surface, but the module should check internally what sensors are available for the fusion. In case of single sensor, an orientation estimate, be it noisy, should still be returned. It's up to the end user to decide how to deal with noisy sensor data.

Desktop

  • React Native Version: 0.71.7
  • Device: Samsung Galaxy A04s, physical device
  • Version: Android 13

@carltian
Copy link

I had to solve it in the native Android module, that is the patch that worked for me using the accelerometer sensor. @ttrvdw react-native-sensors+7.3.6.patch

Describe the bug Orientation is not available for devices that do not have some sensors. e.g. a device with only accelerometer will return "Sensor orientation is not available" error when subscribing to "orientation".
Tested setup: Samsung Galaxy A04s with accelerometer but no gyroscope or magnetometer. Working without error on Samsung Galaxy S8 and iPhone XR.
To Reproduce Steps to reproduce the behavior:
Take phone with accelerometer but no gyroscope nor magnetometer (e.g. Samsung A20).

import {
  orientation,
  SensorTypes,
  setUpdateIntervalForType,
} from 'react-native-sensors';

const subscription = orientation.subscribe(data => {...})

This will return Sensor orientation is not available
Expected behavior The package should check what sensors are available to make the orientation measurements. I suspect that some sensor fusion is happening under the surface, but the module should check internally what sensors are available for the fusion. In case of single sensor, an orientation estimate, be it noisy, should still be returned. It's up to the end user to decide how to deal with noisy sensor data.
Desktop

  • React Native Version: 0.71.7
  • Device: Samsung Galaxy A04s, physical device
  • Version: Android 13

hi, I use your document in my project, but it report a error
TypeError: Cannot read property 'DocumentDir' of null
i find some absolute path in the document, i try to fix it,but failed
WechatIMG132

@omerts
Copy link

omerts commented Dec 6, 2023

This is a showstopper bug for us, it causes the app to crash with a fatal exception:

2023-12-06 13:43:52.126 20244-20292 AndroidRuntime          pid-20244                            E  FATAL EXCEPTION: mqt_native_modules
                                                                                                    Process: com.mipmip, PID: 20244
                                                                                                    com.facebook.react.common.JavascriptException: Sensor orientation is not available, js engine: hermes, stack:

This is from a real device Samsung S6 Lite tablet

@drewdev02
Copy link

I had to solve it in the native Android module, that is the patch that worked for me using the accelerometer sensor. @ttrvdw react-native-sensors+7.3.6.patch

Describe the bug Orientation is not available for devices that do not have some sensors. e.g. a device with only accelerometer will return "Sensor orientation is not available" error when subscribing to "orientation".
Tested setup: Samsung Galaxy A04s with accelerometer but no gyroscope or magnetometer. Working without error on Samsung Galaxy S8 and iPhone XR.
To Reproduce Steps to reproduce the behavior:
Take phone with accelerometer but no gyroscope nor magnetometer (e.g. Samsung A20).

import {
  orientation,
  SensorTypes,
  setUpdateIntervalForType,
} from 'react-native-sensors';

const subscription = orientation.subscribe(data => {...})

This will return Sensor orientation is not available
Expected behavior The package should check what sensors are available to make the orientation measurements. I suspect that some sensor fusion is happening under the surface, but the module should check internally what sensors are available for the fusion. In case of single sensor, an orientation estimate, be it noisy, should still be returned. It's up to the end user to decide how to deal with noisy sensor data.
Desktop

  • React Native Version: 0.71.7
  • Device: Samsung Galaxy A04s, physical device
  • Version: Android 13

how install react-native-sensors+7.3.6.patch?

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

No branches or pull requests

5 participants