p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

deviceShaken() does not work on Android >= 11.0 on Firefox

Open Spaxe opened this issue 3 years ago • 2 comments
trafficstars

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:

  1. Open https://openprocessing.org/sketch/1615161 on Android
  2. Shake the phone
  3. 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++;
}

Spaxe avatar Jul 11 '22 10:07 Spaxe

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.

Spaxe avatar Jul 16 '22 10:07 Spaxe

Update: works on Chrome today... weird. Doesn't work on Firefox.

Spaxe avatar Jul 16 '22 10:07 Spaxe

Hi, can I take this issue?

xinranyu-yuki avatar Oct 20 '22 12:10 xinranyu-yuki

Thanks @xinranyu-yuki. Just assigned you to this issue.

Qianqianye avatar Oct 21 '22 23:10 Qianqianye