Gyroscope twitching

I have a couple of components animated using the gyroscope, so when I move my phone they move as well, but whenever I return to the desktop from an app the components twitch. This isn't just because I have moved the phone to a different orientation, and the controls are trying to catch up, because they move back again after the twitch.

I don't know if this is a bug with the software, or my hardware (I have a one plus X), or where the problem is, but it would be nice if something could be done about it.