Orientation Sensor makes companion app crash sometimes

I tried the following on two devices. IPhone 5 SE and IPad Air.

When testing the first time both companion apps crashed. From one of them i send information about the crash via the companion app. On the tablet came an error message but i wasn't able to capture that.

After that they didn't crash anymore. On my IPad Air I see strange effects. Although the tablet is lying still the compass moves sometimes to a different position. It should always point North. The strange positions are present in the companion as also in the build versions of the app.

offtopic. Canvas is set to none but shows a white background.

CodiCompass.aia (50.2 KB)

Thanks for the report @Peter. I have been able to somewhat randomly replicate the issue. I think we should be able to address it but I'm still trying to determine the root cause.

This happens on the Android's too. It should always point North is NOT true, the orientation seeks a magnetic field; what it finds is usually the Earth's magnetic field but can also point to a metal desk top or filing cabinet or anything generating or distorting a slight magnetic field. Test this type of app away from metal objects, motors, appliances and magnets and you may have a different result. :slight_smile:

The same problem happens in this project (which I found in the gallery) in AccelerometerSensor component

  • The companion crashes after a certain time
  • In addition, I noticed that the change of orientation causes the components in the canvas to move out of place (even after returning to the previous orientation position)
    FindTheGoldApp.aia (181.4 KB)

So the crash seems to be due to something being garbage collected that shouldn't. This results in a null object that is then used for dispatching an event. I'm not sure what is causing the object reference to be GCed when seemingly they are still live.

1 Like

It's also sometimes the case that the sensor needs to be calibrated. One trick is to place the device flat on your hand and move it in a figure 8 form and sometimes this corrects the bias in the sensor. For the most part it seems fairly accurate on my iPhone but I can also fake it out by moving it rapidly and placing it next to my laptop.

Yes that advice is on the web. It has never worked for me. A moving indicator is more likely a changing magnetic field. Find your boy's scout compass (you probably have one or can borrow one); place it near your Android or iOS and have fun though a sudden movement of the sprite used as a North arrow might be a software issue too.

Incidentally, there isn't a hardware orientation sensor and orientation sensor's do not exist on many modern Androids. Orientation sensor is industry deprecated I believe. The system computes the orientation angles by using a device's geomagnetic field sensor in combination with the device's accelerometer. Using these two hardware sensors , the system provides data for the following three orientation angles: Azimuth (degrees of rotation about the -z axis), Pitch and Roll.

I think you are right. Didn't happen when i tested it with the tablet away from anything. I also think my iphone is less vulnerable to this kind of behavior.