aframe icon indicating copy to clipboard operation
aframe copied to clipboard

device-orientation-permission-ui incorrectly emits deviceorientationpermissiongranted too early

Open diarmidmackenzie opened this issue 3 years ago • 2 comments
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.

diarmidmackenzie avatar Jul 15 '22 16:07 diarmidmackenzie

Thanks!

dmarcos avatar Jul 15 '22 22:07 dmarcos

You can close the issue, the PR has been merged.

vincentfretin avatar Sep 10 '22 14:09 vincentfretin

fixed by https://github.com/aframevr/aframe/pull/5079

dmarcos avatar Nov 17 '22 21:11 dmarcos