p5.js
p5.js copied to clipboard
deviceShaken() does not work on Android >= 11.0 on Firefox
Most appropriate sub-area of p5.js?
- [ ] Accessibility (Web Accessibility)
- [ ] Build tools and processes
- [ ] Color
- [ ] Core/Environment/Rendering
- [ ] Data
- [ ] DOM
- [X] Events
- [ ] Friendly error system
- [ ] Image
- [ ] IO (Input/Output)
- [ ] Localization
- [ ] Math
- [ ] Unit Testing
- [ ] Typography
- [ ] Utilities
- [ ] WebGL
- [ ] Other (specify if possible)
p5.js version
1.4.1
Web browser and version
Firefox 102.2.0
Operating System
Android 11 & Android 12
Steps to reproduce this
Steps:
- Open https://openprocessing.org/sketch/1615161 on Android
- Shake the phone
- notice that the acceleration numbers show up on iOS Firefox and Android on Chrome. on Android Firefox it's
NaN
I have tried three different Android phones to no avail.
I also note that the deviceShaken() example page on p5.js reference doesn't run.
https://p5js.org/reference/#/p5/deviceShaken
https://p5js.org/reference/#/p5/accelerationX works on my Android 12
Snippet:
let shakenCount = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
noLoop();
//request access to Device Motion API.
OpenProcessing.requestDeviceMotion()
.then(function() {
setShakeThreshold(5);
//Once user gives access, this function is called.
//Also, all the P5js acceleration variables and functions are accessible.
loop();
})
noStroke();
textAlign(CENTER);
textSize(32);
}
function draw() {
background(255);
text("x: " + accelerationX, width / 2, height / 5);
text("y: " + accelerationY, width / 2, 2 * height / 5);
text("z: " + accelerationZ, width / 2, 3 * height / 5);
text("shaken: " + shakenCount, width / 2, 4 * height / 5);
}
function deviceShaken() {
shakenCount++;
}
I tested the deviceShaken() once more: https://openprocessing.org/sketch/1615161
Still doesn't work on Android 12, works on iPad 15.
Also discovered that https://p5js.org/reference/#/p5/accelerationX works on my Android 12 ... so I'm not sure how or why.
Update: works on Chrome today... weird. Doesn't work on Firefox.
Hi, can I take this issue?
Thanks @xinranyu-yuki. Just assigned you to this issue.