processing / processing/p5.js

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

Open
#5,718 5 comments 0 reactions 1 assignee View on GitHub

@xinranyu-yuki is already working on this.

Since Oct 21, 2022.

Area:Events Bug Help Wanted Patch
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Most appropriate sub-area of p5.js?
  • Accessibility (Web Accessibility)
  • Build tools and processes
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • 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++;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.