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

[WIP] Handle nondeterministic paint worklet registration #20269

Closed

Conversation

wabain
Copy link

@wabain wabain commented Mar 11, 2018

When different global paint worklet scopes register document paint definitions of the same name with different parameters, the registration should be marked invalid [1]. Currently, Servo unconditionally overwrites any prior registrations when a new definition is received.

This commit passes the parameters from the paint worklet global scope through to the layout thread so that they can be tracked there. In the absence of support for parsing input arguments, I'm passing the length of the input argument vector as a placeholder.

TODO:

  • When the act of registering a paint class in the first place is non-deterministic, a paint worklet global scope may attempt to invoke a paint callback for a class it has not registered. When this happens, the spec states that the document paint definition should be invalidated and an invalid image should be output [2]. Currently, only the latter happens.

  • No tests yet. It's pretty easy to generate conflicting registrations manually, but I don't think it's possible to make this fully deterministic without a stateful server component or something.

[1] https://drafts.css-houdini.org/css-paint-api/#registering-custom-paint
[2] https://drafts.css-houdini.org/css-paint-api/#invoke-a-paint-callback


  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

When different global paint worklet scopes register document
paint definitions of the same name with different parameters, the
registration should be marked invalid [1]. Currently, Servo
unconditionally overwrites any prior registrations when a new
definition is received.

To implement this check, this commit passes the parameters from the
paint worklet global scope through to the layout thread. In the
absence of support for parsing input arguments, the length of the
input argument vector is passed as a placeholder.

There's still a hole left in this implementation. When the act of
registering a paint class in the first place is non-deterministic,
a paint worklet global scope may attempt to invoke a paint callback
for a class it has not registered. When this happens, the spec states
that the document paint definition should be invalidated and an
invalid image should be output [2]. Currently, only the latter happens.

[1] https://drafts.css-houdini.org/css-paint-api/#registering-custom-paint
[2] https://drafts.css-houdini.org/css-paint-api/#invoke-a-paint-callback
@highfive
Copy link

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @mbrubeck (or someone else) soon.

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/script_thread.rs, components/script/dom/workletglobalscope.rs, components/script/dom/paintworkletglobalscope.rs
  • @KiChjang: components/script/script_thread.rs, components/script/dom/workletglobalscope.rs, components/script/dom/paintworkletglobalscope.rs
  • @fitzgen: components/script/script_thread.rs, components/script/dom/workletglobalscope.rs, components/script/dom/paintworkletglobalscope.rs
  • @emilio: components/layout/display_list/builder.rs

@highfive
Copy link

warning Warning warning

  • These commits modify layout and script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 11, 2018
When a custom paint is not always registered when its module is
run, a paint worklet global scope may receive a request to invoke
a paint callback for a paint it does not have registered. When this
happens, the document's paint definition should be invalidated.
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #20900) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 2, 2018
@mbrubeck mbrubeck removed their assignment Jan 3, 2022
@wabain wabain closed this Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paint worklets: Mark nondeterministic registration as invalid
4 participants