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

Revise AWN/AWP construction process #2022

Merged
merged 13 commits into from
Aug 17, 2019

Conversation

hoch
Copy link
Member

@hoch hoch commented Aug 12, 2019

This is an attempt to fix #2021.

Key changes:

  • A new algorithm is introduced: "invoking AWP constructor with processor construction data"
  • The "processor construction data" is now defined clearly.
  • The AWN constructor will now explicitly trigger the algorithm above.
  • The AWP constructor does not have infinite loop anymore.

cc @bzbarsky


Preview | Diff

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@hoch hoch closed this in #2024 Aug 14, 2019
@hoch hoch reopened this Aug 14, 2019
@hoch hoch requested a review from rtoy August 14, 2019 18:29
Copy link
Member Author

@hoch hoch left a comment

Choose a reason for hiding this comment

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

PTAL again @bzbarsky.

I wouldn't say this is a perfect solution, but it's "A" direction to utilize implicit construction data. Let me know what you think.


1. Make <dfn><var>nodeReference</var></dfn>,
<dfn><var>deserializedPort</var></dfn>, and
<var>deserializedOptions</var> available
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a new concept of "making things available" for the AWP constructor.

Choose a reason for hiding this comment

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

OK, but what does this concept mean? How do we expect a UA to actually implement this?

As discussed earlier, fixing this in a separate PR is fine if that helps.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I would like to merge the progress in this PR, and follow-up on this part later.

index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated
<var>deserializedOptions</var> available
for the execution of <var>processorCtor</var>.

1. Invoke the <var>processorCtor</var> with the argument of

Choose a reason for hiding this comment

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

What does "Invoke" mean here? Does this mean https://heycam.github.io/webidl/#invoke-a-callback-function or https://heycam.github.io/webidl/#construct-a-callback-function or something else?

Seems to me like this should https://heycam.github.io/webidl/#construct-a-callback-function at first glance, since processorCtor is an AudioWorkletProcessorConstructor, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps it's better to say Perform Construct(processorCtor, deserializedOptions) like the step 9 of https://heycam.github.io/webidl/#construct-a-callback-function.

I am not sure deserializedOptions is a valid ES value. Probably it needs a conversion?

Choose a reason for hiding this comment

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

Why would we prefer Construct over "construct a callback function", especially since what we have is in fact a callback function? I mean, we can do a manual Construct but then we will need to also manually duplicate a lot of the bookkeeping "construct a callback function" does for us, no?

deserializedOptions is the return value of a StructuredDeserialize call, right? That would be an ES value, as defined at https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserialize

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have any preference here. I am merely focusing two things: your suggestion and minimizing changes.

I mean, we can do a manual Construct but then we will need to also manually duplicate a lot of the bookkeeping "construct a callback function" does for us, no?

It sounds like you're constructing a callback function, but not executing the constructor itself. I was mistaken. If this is the correct way of performing the constructor (processorCtor), then I am all for it.

Also the algorithm has some interesting bits:
"Let relevant settings be realm’s settings object."

Is this "setting object" similar to "processor construction data"? Then this algorithm might be a solution for our situation.

deserializedOptions is the return value of a StructuredDeserialize call, right? That would be an ES value

Understood.

Choose a reason for hiding this comment

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

If this is the correct way of performing the constructor

Yes, it is.

Is this "setting object" similar to "processor construction data"?

No, it's the thing defined at https://html.spec.whatwg.org/multipage/webappapis.html#settings-object

Copy link
Member Author

Choose a reason for hiding this comment

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

ACK


1. Make <dfn><var>nodeReference</var></dfn>,
<dfn><var>deserializedPort</var></dfn>, and
<var>deserializedOptions</var> available

Choose a reason for hiding this comment

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

OK, but what does this concept mean? How do we expect a UA to actually implement this?

As discussed earlier, fixing this in a separate PR is fine if that helps.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved

1. Let <var>deserializedPort</var> be the result of
[$StructuredDeserialize$](<var>serializedPort</var>,
the current Realm).

Choose a reason for hiding this comment

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

What current Realm? There is no current Realm here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, then how do we deserialize the transferred data without a realm? I took the text for granted when I got some help from @domenic. Perhaps the realm should be given to the algorithm from the call site?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also this algorithm is performed in AudioWorkletGlobalScope so there is a defined "current realm", I think.

Choose a reason for hiding this comment

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

You want the realm of the AudioWorkletGlobalScope, but it's not the current realm at that point. In order for it to be the current realm, you'd have to have a running execution context, which can only happen if something pushes it on the execution context stack, etc. None of that is happening here.

What you probably want to say is that deserialization is passed the realm of the AudioWorkletGlobalScope involved. It doesn't look like ES really defines getting the realm of a global; I guess you can say you use the realm whose [[GlobalObject]] is the AudioWorkletGlobalScope that corresponds to the BaseAudioContext of the AudioWorkletNode that we're in the middle of creating....

Choose a reason for hiding this comment

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

I guess maybe https://html.spec.whatwg.org/multipage/webappapis.html#concept-global-object-realm offers a shortcut, so you can just talk about taking the realm of the AudioWorkletGlobalScope etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the pointer, but this is really out of scope of this PR. I file a new issue and work on a new PR for it.

Copy link
Member

@rtoy rtoy left a comment

Choose a reason for hiding this comment

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

Mostly just nits/typos. Fix them as needed and looks good to me.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
@hoch hoch merged commit 1d1a03b into WebAudio:master Aug 17, 2019
@hoch
Copy link
Member Author

hoch commented Aug 17, 2019

Merging after an approval. I opened #2027 for some issues raised in this PR.

@hoch hoch deleted the 2021-constructor-recursion branch August 21, 2019 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AudioWorkletProcessor constructor leads to infinite recursion
3 participants