Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a sensor interfaces to sensor features #2299

Merged
merged 6 commits into from
Dec 12, 2024
Merged

Conversation

Elchi3
Copy link
Collaborator

@Elchi3 Elchi3 commented Nov 21, 2024

See https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs

Specific sensors:

@github-actions github-actions bot added the feature definition Creating or defining new features or groups of features. label Nov 21, 2024
@Elchi3 Elchi3 mentioned this pull request Nov 21, 2024
@autonome
Copy link
Collaborator

@Elchi3 Is this usable in the absence of a specific sensor? Review feedback on "base class" types of features so far has been to bundle them w/ the first usable implementation.

@Elchi3
Copy link
Collaborator Author

Elchi3 commented Nov 27, 2024

hm, what is the first usable implementation or specific sensor here? Looks like there is varying support and even re-implementations on top of "generic sensors" (this API).

@captainbrosset
Copy link
Contributor

Yeah, I don't think we should create a feature just with those keys, because they don't represent a thing developers can use. This is an interesting case where we'd almost need these BCD keys to be duplicated into each of the features that use Sensor as a base class.

Why don't we allow duplication of BCD keys by the way? @ddbeck?

BCD keys:

  • api.Sensor
  • api.Sensor.activate_event
  • api.Sensor.activated
  • api.Sensor.error_event
  • api.Sensor.hasReading
  • api.Sensor.reading_event
  • api.Sensor.start
  • api.Sensor.stop
  • api.Sensor.timestamp
  • api.SensorErrorEvent
  • api.SensorErrorEvent.SensorErrorEvent
  • api.SensorErrorEvent.error

Classes that inherit from Sensor

@captainbrosset
Copy link
Contributor

We just discussed about this PR on the WebDX CG call (minutes).

The options seem to be the following:

  • Ignore the generic Sensor BCD keys (at least for now).
  • Bundle these keys with whichever feature came first, as suggested by Dietrich.
  • Duplicate the keys among all of the features that derive from the generic Sensor class.
  • Create a generic Sensor feature.

I don't want to block this PR, but I do want to express my opinion, which is that we should either ignore the keys for now, or fold them under one of the concrete sensor classes (not sure which one). If people feel strongly that we need a Sensor feature, then I won't block the PR either.

I'm having trouble seeing the value of creating a standalone generic Sensor feature in this repo. This repo is used to generate summarized browser support data for features that web developers want to use.
If a dev wants to use the AmbientLightSensor to implement a use case in their app, then we should have a feature for it, which gives them the right browser data.
Can developers use the Sensor class on its own? I don't think so. Do they think about the Sensor class separately from the rest? Maybe, not sure. We should maybe do some customer research here.

Now, during the meeting, the learning argument was brought forward. That a dev would have to learn about the Sensor interface anyway, because that's what gives them at least half of the methods/events that they'll end up using. My counter argument here is that I don't think web-features needs to care about that too much. Web-features cares about "entry points", about the features that are in devs' minds. Web-features answers questions like "Is there a feature to detect light?", "Where is that feature supported?"

@ddbeck
Copy link
Collaborator

ddbeck commented Nov 29, 2024

Why don't we allow duplication of BCD keys by the way? @ddbeck?

This came at MDN's request, when feature authoring was considerably less sophisticated. It was (and is) ambiguous where an MDN page's status ought to come from, if the compat key can be in multiple features. I'm going to ask the MDN folks soon about their current perspective on this.

Duplicate the keys among all of the features that derive from the generic Sensor class

I agree that this is the long-term correct answer. AFAICT, you can't do anything useful with the Sensor API without a concrete physical sensor (or virtual sensor, in the case of webdriver) and its attendant interface additions.

In the mean time…

Bundle these keys with whichever feature came first, as suggested by Dietrich

I think this is the correct way forward, if it's possible. The process would look like this: compare all the concrete sensor implementations and find the least common denominator (i.e., the sensor that is oldest and mostly widely implemented).

I could imagine cases where this wouldn't work very cleanly (e.g., if the most widely implemented sensor is not the oldest). In that case, I'd say we ought to set aside these keys and work to resolve #1173 quickly.

@ddbeck
Copy link
Collaborator

ddbeck commented Dec 10, 2024

I could imagine cases where this wouldn't work very cleanly (e.g., if the most widely implemented sensor is not the oldest). In that case, I'd say we ought to set aside these keys and work to resolve #1173 quickly.

I talked to MDN about #1173 on Thursday. They said they'd be open to us proceeding with keys in multiple features, but not before January. I think the right thing to do here then is:

  • In this (or a superseding PR), assign Sensor keys to all the concrete physical sensor features.
  • For each key that appears in two or more features, comment out the key from all but the most historical feature(s).
  • In a draft PR, uncomment the overlapping keys.

@Elchi3
Copy link
Collaborator Author

Elchi3 commented Dec 11, 2024

Added the generic Sensor interfaces to all specific sensors (except Magnetometer, that's still in a separate PR).
Where should I leave it in and what should be commented out?

@Elchi3 Elchi3 changed the title Add a sensors feature Add a sensor interfaces to sensor features Dec 11, 2024
Copy link
Collaborator

@ddbeck ddbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the dists, it looks like orientation-sensor has the oldest, least complicated support story involving Sensor. I suggest you comment out the keys in all but that one feature. Though it appears that the keys might've been added to a feature erroneously; see line comment. Thank you!

features/device-orientation-events.yml Outdated Show resolved Hide resolved
@Elchi3 Elchi3 requested a review from ddbeck December 12, 2024 09:57
@ddbeck ddbeck merged commit 4204e40 into web-platform-dx:main Dec 12, 2024
3 checks passed
@Elchi3 Elchi3 deleted the sensors branch December 12, 2024 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature definition Creating or defining new features or groups of features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants