FutureCake
FutureCake

Reputation: 2943

How to solve a problem with devicemotion script?

I'm not sure if this is the right place to ask, but I have a problem with my devicemotion script.

I have some code that runs when the page is loaded to check if there is a gyroscope available or not. I do this in the following way:

function check_user_hardware(){

    if (mobile_size <= 600) {
        hidden = true;
    }
    console.log("checking hardware");
    giro_timer = setTimeout(update_gyro_value, 30);
    window.addEventListener("devicemotion", function(event){
        console.log("device motion?");
        if(event.rotationRate.alpha || event.rotationRate.beta || event.rotationRate.gamma){
            calculate_rotation_mesh_pos(event.rotationRate.beta, event.rotationRate.gamma);
            if (!gyroscope) {
                gyroscope = true;
                console.log("gyroscope here");
                current_interaction_mode = 'gyroscope_option';
                set_user_ui_elements();
            }
        }else{
            followMouse = true;
            console.log("no gyroscope here");
            current_interaction_mode = 'followMouse_option';
            set_user_ui_elements();
            window.addEventListener('mousemove', get_user_mouse_pos);
        }
    });
}

This worked just fine a few weeks ago, but now it is not working anymore. I see in console the following prints:

checking hardware

and thats it. Why isn't my devicemotion event firing? Even on my website with basic SSL encryption it is not working, why? Do I need some sort of special SSL encryption?
What is this happening? All suggestions are welcome!
If more information is needed I will be happy to provide.
You can see the website in question here: gravient.thomashoek.com

Upvotes: 15

Views: 1413

Answers (1)

gpanneti
gpanneti

Reputation: 1

I'm facing the same problem on my webapp. I saw that there was an issue concerning the accelerometer on Chromium 62 but it seems that it has been fixed in the v.63.

However the 'devicemotion' event is not working anymore on chrome Android on my side neither (but working perfectly on iOS).

Upvotes: 0

Related Questions