question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

enterVR function does not work in setTimeout

See original GitHub issue

Calling document.querySelector('a-scene').enterVR() from within setTimeout does not work on Chrome for Android . Throws:

webvr-polyfill.js:6442 Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause(). https://goo.gl/LdLk22
M.release @ webvr-polyfill.js:6442
A @ webvr-polyfill.js:1308

a-scene.js:178 Uncaught (in promise) Error: Failed to enter VR mode (`requestPresent`): Unable to present.
    at i (a-scene.js:178)
    at <anonymous>

and aframe does not enter in VR mode.

Actual code:

setTimeout(function(){
    document.querySelector('a-scene').enterVR();
}, 2000);

Although, if I type document.querySelector('a-scene').enterVR(); from console, it works as expected.

On Chrome (version 64.0.3282.186) for Linux (Elementary OS 0.4.1 based on Ubuntu 16.04): If I try this from setTimeout, aframe does enter in VR mode but not in fullscreen, from console without setTimeout it works as expected

  • A-Frame Version: 0.7.0
  • Platform / Device: Chrome on Android and Linux version 64.0.3282.137
  • Reproducible Code Snippet or URL: https://codepen.io/JFarrow/full/pNmdXa/ (same issue happens on any web page)

If you need any more information pardon me and please ask.
Thanks, a lot for this library.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dmarcoscommented, Nov 4, 2019

Browsers are starting to enforce user gesture as well to access the motion sensors (DeviceMotionEvents). More context: https://github.com/aframevr/aframe/issues/4287

1reaction
dmarcoscommented, Nov 4, 2019

Chrome for iOS might not be applying the standard policy

Read more comments on GitHub >

github_iconTop Results From Across the Web

function in setTimeout doesn't work [duplicate] - Stack Overflow
Because I want to deliver parameters into function so I can't just only use function name in setTimeout like setTimeout(hello1, 3000);.
Read more >
setTimeout() - Web APIs | MDN
Working with asynchronous functions. setTimeout() is an asynchronous function, meaning that the timer function will not pause execution of ...
Read more >
Fix JavaScript setTimeout not working - Weekend Projects
The `setTimeout` function can come in handy for delaying execution. We go over few reasons why the settimeout function is not working -...
Read more >
Scheduling: setTimeout and setInterval
Usually, that's a function. For historical reasons, a string of code can be passed, but that's not recommended. delay: The delay before run,...
Read more >
Using setTimeout in React components (including hooks)
Be careful, though, not to just place it anywhere in your function components, as this may run on every re-render. If we want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found