Skip to content

[css-animation-worklet] IDL for AnimationWorkletGlobalScope is invalid #907

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

Closed
bzbarsky opened this issue Jun 27, 2019 · 5 comments
Closed
Assignees
Labels
css-animationworklet-1 CSS AnimationWorklet API

Comments

@bzbarsky
Copy link

The IDL says:

[ Exposed=AnimationWorklet, Global=AnimationWorklet ]
interface AnimationWorkletGlobalScope : WorkletGlobalScope {

but the definition of WorkletGlobalScope at https://drafts.css-houdini.org/worklets/#the-global-scope says:

[Exposed=Worklet]
interface WorkletGlobalScope

So WorkeltGlobalScope is only exposed in "Worklet" scopes, AnimationWorkletGlobalScope is not a "Worklet" scope, and the IDL spec says:

If an interface X inherits from another interface Y then the exposure set of X must be a subset of the exposure set of Y.

In this case that condition is violated.

You probably want Global=(AnimationWorklet, Worklet) here.

@lukebjerring
Copy link
Contributor

This should have been covered/caught in the animation-worklet/idlharness.any.js WPT test:
https://wpt.fyi/results/animation-worklet/idlharness.any.html?label=master&label=experimental

Will address with web-platform-tests/wpt#17551

@majido majido added the css-animationworklet-1 CSS AnimationWorklet API label Jun 27, 2019
@majido majido self-assigned this Jun 27, 2019
@majido
Copy link
Contributor

majido commented Jun 27, 2019

Thanks for catching this. I will fix this in the spec per your proposed solution which makes sense.

I will ask some of our more seasoned spec writers to do a check on the spec to ensure we catch other mistakes like this as well.

@majido
Copy link
Contributor

majido commented Jun 27, 2019

So just to be clear. Is it enough that we do

A) expand global list for AnimationWorkletGlobalScope to be Global=(AnimationWorklet,Worklet)

[Exposed=Worklet]
interface WorkletGlobalScope {};

[ Exposed=AnimationWorklet, Global=(AnimationWorklet, Worklet) ]
interface AnimationWorkletGlobalScope : WorkletGlobalScope {}

or do I also need to do

B) expand exposure set of WorkletGlobalScope

[Exposed=(AnimationWorklet, Worklet)]
interface WorkletGlobalScope {};

[ Exposed=AnimationWorklet, Global=(AnimationWorklet, Worklet) ]
interface AnimationWorkletGlobalScope : WorkletGlobalScope {}

If I understand correctly the original comment suggests that (A) is sufficient because by making AnimationWorkletGlobalScope to also be a Worklet global then the exposure set Exposed=AnimationWorklet also becomes a subset of Exposed=Worklet which means we satisfy the quote requirement without having to change the exposure set of WorkletGlobalScope

@bzbarsky
Copy link
Author

(A) is enough.

@tabatkins
Copy link
Member

Phew, I've had to reread the sections on Exposed and Global multiple times before I finally understood what was going on here.

So, [Global] has two independent purposes. First, it marks the interface as a global, which means that (in prose) an environment can say that is uses a singular instance of the interface as its global object (and some other weird mechanical stuff that's not relevant here).

Second, it advertises one or more names that other interfaces can use in [Exposed] to claim that they're exposed in that global. Multiple interfaces can advertise the same global name, which just means that interfaces that are [Exposed] to that name show up in all those globals. In this way, a shared [Global] name acts similar to a superclass in normal inheritance hierarchies.

So WorkletGlobalScope and its subclasses are mixing two different "inheritance" systems here. First, WGS itself is an "abstract" superclass of all the specific worklet globals, like AnimationWorkletGlobalScope or PaintWorkletGlobalScope, so we can define methods there that'll show up in all the worklet globals.

Then the specific subclasses actually mark themselves as globals, advertising both a specific name and the generic name "Worklet", so that interfaces/methods/etc can choose to expose themselves either to a specific worklet type, or to all worklets.

WorkletGlobalScope, then, is marked [Exposed=Worklet], because obviously its methods want to show up in every worklet. It's not marked with any [Global], because you can't have subclasses if you're a global.


I feel like this example should really be illustrated in WebIDL; it's used by both Workers and Worklets, but is (to me, at least) a very non-obvious twisty sort of interaction of these features. Compare to the much simpler Window example, which is a global and exposed to itself immediately. I'll open an issue for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-animationworklet-1 CSS AnimationWorklet API
Projects
None yet
Development

No branches or pull requests

4 participants