processing / p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
http://p5js.org/
GNU Lesser General Public License v2.1
21.7k stars 3.34k forks source link

deviceShaken() not triggered on iOS 13+ #4367

Open paolobaiguera opened 4 years ago

paolobaiguera commented 4 years ago

Most appropriate sub-area of p5.js?

Details about the bug:

Here's my code.

deviceEventNotFired.docx

Oddly enough this one actually works on my phone https://editor.p5js.org/kan352/sketches/HJbxxRwWg

welcome[bot] commented 4 years ago

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

limzykenneth commented 4 years ago

It could possibly be a permission issue, I don't have an Android device to test but on iOS all of the accelerometer functions are not working because they now require an additional call to ask the users for permission to get the data. See more here. See also #4037.

A way to test whether it is the same problem for you, add the following to your code and press the button created, it should ask for permission and the sketch should work as expected.

function setup(){
    btn = createButton("Motion");
    btn.mousePressed(function(){
        DeviceOrientationEvent.requestPermission();
    });
}
paolobaiguera commented 4 years ago

Sorry for the long wait.. It was both the suggested problema and the fact that i did not use https (for Android). However deviceShaken() still not work on iOS 13+.

limzykenneth commented 4 years ago

@paolobaigueraunitn Does it still not work with the example code I posted above? In iOS Safari you may need to enable it in Preferences as well.

paolobaiguera commented 4 years ago

I enabled preferences and It still did not work. It's a rather weird issue since it actually gives me the accX,Y,Z values and it's therefore able to access the accelerometer. In android it works perfectly, but it does not respond in iOS 13+ at all.

limzykenneth commented 4 years ago

That's odd. Are you using 1.0.0 version of the library? If you can try and get a inspector running in desktop Safari connected to the mobile Safari and see if it gives any error or something. I don't have the capacity to test this out fully myself so if you can help debug this that would be very helpful! Thanks.

paolobaiguera commented 4 years ago

I'll try and get back to you! Sorry, but i'm dealing with this within a project so I've got a rather big amount of issues to get past me so I'll do this as soon as i can.

paolobaiguera commented 4 years ago

Hi! I manage to check it. No error is displayed. Everything's works fine except for the deviceShaken() method in iOS 13+. There are ofCourse some workarounds, but they are pretty complicated (in my case I recurred to some DNN stuff...). Sorry I could not help more.

Thanks.