accelerationXYZ doesn't seem to work on Android
accelerationXYZ doesn't seem to work on Android
- [x] Found a bug
- [ ] Existing feature enhancement
- [ ] New feature request
Most appropriate sub-area of p5.js?
- [ ] Color
- [ ] Core
- [ ] Data
- [ ] Events
- [ ] Image
- [ ] IO
- [ ] Math
- [ ] Typography
- [ ] Utilities
- [ ] WebGL
- [x] Other (reading mobile sensor data)
Which platform were you using when you encountered this?
- [x] Mobile/Tablet (touch devices)
- [ ] Desktop/Laptop
- [ ] Others (specify if possible)
Details about the bug: The Accelerometer data 3D example
http://alpha.editor.p5js.org/shiffman/sketches/BJxoCbdxx seems to work on iOS, but not Android
- p5.js version: v0.5.14 August 28, 2017
- Web browser and version: Chrome
- Operating System: iOS 9 / Android 5.1
- Steps to reproduce this: Open http://etterstudio.com/lab/p5/example/ on Chrome on Android, there is no sensor data, however it does work opening same URL on iOS
What Android device are you using? Also can you check the sketch via https links, I'm not sure the browsers on Android have already implemented it but there are plans to limit device acceleration usage to secured sites only so that may be your problem.
I don't have an Android device to test this out so any help is appreciated.
Thanks @limzykenneth for your response!
- I have enabled HTTPS but the result is still the same.
- It's an Wiko Lenny 3 phone running now Android 6.0 and latest Chrome
This is working fine for me on a Sony Xperia Z1 - android 5.1.1 on Chrome 61.0.3163.98 without HTTPS.
@etterstudio can you try opening this device orientation demo on your phone: http://wellcaffeinated.net/demos/device-orientation if this doesn't work either, I'd suspect your device just doesn't support device orientation. but if it does, there could be something we're not accounting for in the p5 library
@mlarghydracept do you want to look into this one? if it's not reproducible, we can close it for now
http://wellcaffeinated.net/demos/device-orientation does work on this device. Generally getting data via window.ondevicemotion works on this device, just not via P5. But it could have to do with the device (I don't think it's a very popular model)
I have a similar issue on my Huawei Honor 8 running EMUI 5.0.1 on Android 7.0.0; Chrome 65.0.3325.109. Hardware sensors work fine according to monitoring apps.
My mobile browser seems unable to catch window.ondevicemotion events. On my phone they are only triggered when the window goes from inactive to active, and return a DeviceMotionEvent with null x, y, z values.
window.ondeviceorientation seems to work properly, as well as rotationXYZ. In fact, in https://p5js.org/examples/mobile-acceleration-ball-bounce.html (in which the ball stays on top left on mobile Chrome) for example, replacing the variables accelerationXYZ to rotationXYZ seemed to produce the intended behavior.
I've tried with a few other browsers and got the same non-working results with Opera Mini 32 and Edge. Firefox 58.0.2 interestingly was somewhat responsive to window.ondevicemotion, but only intermittently (like once every second or so) when I shake the phone a lot.
Perhaps it has to do with how different browsers handle devicemotion. Unfortunately I can't dig deeper now, but will be happy to return to this at a later time.
Similar issue with google Pixel with chrome 65.0.3325.109. devicemotion stopped working correctly. Works great on same device with FF
Hi @etterstudio @achimkoh @benz2013, thanks for all your reports! Unfortunately I don't have an Android device to test this but I hope you can help debug this issue if at all possible. Basically we need to narrow down the problem by answering a few questions first:
- Is it device specific, ie happens on certain devices only
- Is it browser specific, ie on the same device some browser works but some don't
- Is it p5.js specific, ie does the issue affect all devicemotion in the browser or just in p5.js
Thanks for your help and don't worry if you won't be able to help out at this moment. 😃
Hi there. I'm looking into this issue and it appears to be device specific so far in my tests. I have two Android devices I was able to test this on:
1st device (Infinix X572) - examples work in Chrome and in it's native browser. 2nd device (Lenovo Tab S8-50) - none of the above examples work. But sensor data shows accelerometer is working fine.
I am unable to replicate this on the emulators I'm using for my GSOC project. As @limzykenneth mentioned, answering those questions would be helpful for anybody looking at this. I would like to make a note of the known devices where this is an issue.
Thank you everyone testing this 🙂
The events appear to be triggered on my Nexus 5X in Chrome. (I can get the exact version numbers if they're helpful)
Here's another sketch I used to test: http://alpha.editor.p5js.org/full/r1BHB1hz7
I noticed in that in src/core/core.js there's a conditional that checks that the DeviceMotionEvent exists before creating the conditions for devicemoved to be installed. I wonder if this doesn't check out for some reason on some platforms? This new sketch reports the two values that are used in the p5 conditional for installing the listener (albeit, later than setup time). If you have a device where this is known not to work, please have a look and let us know the results @LadySith, @benz2013, @achimkoh, @etterstudio — thanks!
Note also: Opera Mini does not appear to support ondevicemotion on any platform.
Since we weren't able to reproduce this one and haven't received any further updates, I'm going to close this for organizational purposes. Please feel free to comment and we can reopen if there is more info to help debug.
Hi, the real issue is that it does not work on chrome.
Confirmed this does not work on chrome for Android over HTTP. With HTTPS, it works.