Intent to Prototype: Implement requestPermission() for DeviceOrientationEvent and DeviceMotionEvent

209 views
Skip to first unread message

Raphael Kubo da Costa

unread,
Jun 20, 2022, 9:15:37 AM6/20/22
to blink-dev

Contact emails

raphael.ku...@intel.com, eng...@chromium.org, rei...@chromium.org

Explainer

None

Specification

https://w3c.github.io/deviceorientation

Summary

Allows developers to ask for permission to start using the Device Orientation and Device Motion APIs. Access to these APIs is currently granted by default, and these new functions are part of the plan to start prompting for access in the future.



Blink component

Blink>Sensor>DeviceOrientation

Motivation

The Device Orientation spec is more than a decade old, at a time when integration with the Permissions spec was not common (or possible). As such, developers can use the window.ondevice{motion,orientation} events without having to ask for permission before reading sensor data. A few years ago, the WebKit team added the requestPermission() functions to DeviceOrientationEvent and DeviceMotionEvent when implementing the spec, so that websites would have to ask for permission before being able to use the API. This is the case on Safari for iOS at the moment. We want to do the same thing and avoid allowing websites access to sensor data by default. Doing this in Chromium is more complicated because the API is already implemented, and requiring developers to add requestPermission() to their websites out of the blue can risk breaking the web. In this first step, the idea is to just add the API and make it report "granted" or "denied" without prompting for access (i.e. it just reports the current Motion Sensor permission settings) while also adding user counters to understand how many pages are already using the requestPermission() calls and how many pages are just using window.ondevice{motion,orientation} without it. We will then evaluate how to switch to prompting by default in the future, as discussed in the tracking bug.



Initial public proposal



Search tags

device orientation, device motion

TAG review



TAG review status

Not applicable

Risks



Interoperability and Compatibility



Gecko: Under consideration (https://bugzilla.mozilla.org/show_bug.cgi?id=1536382)

WebKit: Shipped/Shipping (https://bugs.webkit.org/show_bug.cgi?id=195329)

Web developers: No signals

Other signals: Lots of comments in the Chromium tracking bug over the years

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?



Debuggability

-



Is this feature fully tested by web-platform-tests?

Yes (as part of the CL I am working on)

Flag name



Requires code in //chrome?

False

Tracking bug

https://bugs.chromium.org/p/chromium/issues/detail?id=947112

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5051845089689600

This intent message was generated by Chrome Platform Status.

Joe Medley

unread,
Jun 21, 2022, 1:45:54 PM6/21/22
to Raphael Kubo da Costa, blink-dev
"these new functions are part of the plan to start prompting for access in the future."

Can I assume this means you're going to deprecate default access to window.ondevice{motion,orientation} at some point? 
Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com | 816-678-7195
If an API's not documented it doesn't exist.


--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/a7bfbf70-0cbf-709f-6310-7af1101c2574%40intel.com.

Raphael Kubo da Costa

unread,
Jun 21, 2022, 4:57:10 PM6/21/22
to Joe Medley, blink-dev
Correct. The larger plan is to:
- Require requestPermission() before window.ondevice{motion,orientation} start dispatching events
- Change the UI side to prompt for sensor access when necessary
- Do the same as part of Sensor.start() (meaning Accelerometer.start() etc)

How to get there without breaking websites that do not use requestPermission() is something we are still working out and that will not happen in the short term.

Joe Medley

unread,
Jun 22, 2022, 1:08:17 PM6/22/22
to Raphael Kubo da Costa, blink-dev
What do you think about saying in the summary that we're hoping to deprecate default access to window.ondevice{motion,orientation} in the future?

Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com | 816-678-7195
If an API's not documented it doesn't exist.

Raphael Kubo da Costa

unread,
Jun 24, 2022, 7:16:22 AM6/24/22
to Joe Medley, blink-dev
Done, I've reworded the Summary in chromestatus.com and explicitly mentioned window.ondevice{motion,orientation}, please let me know if that's still unclear.
Reply all
Reply to author
Forward
0 new messages