aframe
aframe copied to clipboard
device-orientation-permission-ui incorrectly emits deviceorientationpermissiongranted too early
trafficstars
Description:
- A-Frame Version: 1.3.0
- Platform / Device: iPhone
- Reproducible Code Snippet or URL: https://premature-granted-event.glitch.me/
Open this on an iPhone, and accept permissions for device orientation.
Logs show that events are created in the following order:
- Granted (this is a bogus event, should not be generated).
- Requested
- Granted
The bug is here
The code is structued as
requestPermission.catch().then()
This means that the "then" branch gets executed even when an exception is caught in the requestPermission. Which results in the behaviour above.
Fix is to switch the catch() and then() branches. I'll submit a PR for this.
Thanks!
You can close the issue, the PR has been merged.
fixed by https://github.com/aframevr/aframe/pull/5079