brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.57k stars 2.28k forks source link

Deviceorientation event not firing on Android until you change the browser settings #30076

Open strrife opened 1 year ago

strrife commented 1 year ago

Description

The deviceorientation event does not seem to work properly on Brave Android with default config. It gets fired once when the listener is added, but lacks any meaningful payload (you get nulls for alpha and other fields), no prompt suggesting to allow the sensor access is shown.

I believe this behaviour was introduced here.

This starts to work when you enable Motion sensors under Settings > Site Settings > Motion Sensors.

I think it would make sense to make Sensors ask for a permission, like Geolocation, instead of failing silently on a clean browser config.

Steps to reproduce

Please consider this simple HTML:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
  <body>
    Alpha: <span id="root"></span>
    <br />
    <button onclick="startShowingAlpha()">Start</button>
    <script type="text/javascript">
      function startShowingAlpha() {
        window.addEventListener('deviceorientation', function (s) {
          document.getElementById('root').innerHTML = s.alpha;
        })
      }
    </script>
  </body>
</html>

It is available here.

  1. Open the sample html.
  2. Click "Start"

Actual result

After clicking start, an event is sent once with alpha set to null. Here's an extremely non-informative screenshot of the orientation listener not working.

Expected result

After clicking start, device orientation events are sent continuously, like in Brave iOS or Chrome (same device).

Issue reproduces how often

Easily reproduced

Version/Channel Information:

Device details

Brave version

1.50.121

Website problems only

Additional information

N/A

firtina-lyfta commented 1 year ago

I ran into this also today.

noahzarro commented 1 year ago

We're observing the same behavior

jankohlbach commented 1 year ago

+1

blakjakau commented 9 months ago

Just adding my +1 to this.

Defaulting permissions to "Blocked" and requiring the a user to delve into settings is pretty gross.

Surely using the "Ask" status by default (as per camera and location) is the most sensible option for this?

TheCodeBender commented 6 months ago

+1 to this. Checks like

if (!window.DeviceOrientationEvent) { // handle no support }

are not working as expected since DeviceOrientationEvent is valid and just returning unusable values.

lonce commented 6 days ago

Yep, still a problem.