enterVR function does not work in setTimeout
See original GitHub issueCalling 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:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Browsers are starting to enforce user gesture as well to access the motion sensors (DeviceMotionEvents). More context: https://github.com/aframevr/aframe/issues/4287
Chrome for iOS might not be applying the standard policy