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

Paint worklets: Mark nondeterministic registration as invalid #17584

Open
asajeffrey opened this issue Jun 30, 2017 · 20 comments · May be fixed by #20269
Open

Paint worklets: Mark nondeterministic registration as invalid #17584

asajeffrey opened this issue Jun 30, 2017 · 20 comments · May be fixed by #20269

Comments

@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jun 30, 2017

@nox
Copy link
Member

@nox nox commented Oct 9, 2017

Where is the code where that should be done?

@asajeffrey asajeffrey removed their assignment Oct 9, 2017
@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Oct 9, 2017

In the code

self.registered_painters.0.insert(name, registered_painter);

Currently we just insert a new registered painter. Really we should check to see if there already is one, and if there is check to make sure its attributes are the same. If they're not, remove the existing definition and replace it by a tombstone.

@kafji
Copy link
Contributor

@kafji kafji commented Oct 14, 2017

Can I give this a try?

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Oct 14, 2017

Go for it!

@KiChjang KiChjang added the C-assigned label Oct 14, 2017
@KiChjang
Copy link
Member

@KiChjang KiChjang commented Nov 6, 2017

@kafji Are you still working on this?

@kafji
Copy link
Contributor

@kafji kafji commented Nov 12, 2017

@KiChjang Yes

@kafji
Copy link
Contributor

@kafji kafji commented Nov 12, 2017

If they're not, remove the existing definition and replace it by a tombstone.

@asajeffrey What is tombstone?

@jdm
Copy link
Member

@jdm jdm commented Nov 13, 2017

I believe it means a value that cannot be used, but represents a value that used to be usable.

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Nov 14, 2017

Indeed, an object representing a failed attempt to register a paint worklet.

@KiChjang
Copy link
Member

@KiChjang KiChjang commented Nov 29, 2017

@kafji Is this still being worked on?

@kafji
Copy link
Contributor

@kafji kafji commented Nov 29, 2017

@jdm jdm removed the C-assigned label Nov 29, 2017
@wabain
Copy link

@wabain wabain commented Mar 8, 2018

I'm interested in working on this, assuming that nothing's changed in the past few months, but I have a few questions:

The spec says that equivalency of paint definitions is determined by equality of "input properties, input argument syntaxes, and PaintRenderingContext2DSettings object". However, currently only the input properties are sent to the layout thread, and parsing the input arguments is left as a TODO in the paint worklet global scope. Does it make sense to do that parsing and then send those parameters to the layout thread for this validation?

Also, the spec says that if the registrations don't match the UA should:

Log an error to the debugging console stating that the same class was registered with different inputProperties, inputArguments, or paintRenderingContext2DSettings.

How would that be done?

@jdm
Copy link
Member

@jdm jdm commented Mar 8, 2018

@asajeffrey Can answer the first question, but the logging can just use println! for the time being.

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 9, 2018

@wabain probably just easiest to treat the properties as strings, and ignore the arguments. If you want to add support for the argument syntaxes, that would be great, but it probably means implementing a lot more of the typed CSS object model!

@wabain
Copy link

@wabain wabain commented Mar 11, 2018

Sounds good! I'm opening a WIP PR with a first-pass implementation. There's still some work needed to invalidate the document paint definition if a paint worklet finds that the painter wasn't ever registered in its scope. I also don't know if there's a good way to add a deterministic reftest for this, or if there's a threshold where a fallible reftest is good enough (e.g. if it will produce a conflict > 99% of the time).

@wabain wabain linked a pull request that will close this issue Mar 11, 2018
4 of 7 tasks complete
@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 12, 2018

@wabain yes, testing this is going to be painful, since we'd need to mock up a worklet that is guaranteed to execute differently on different loads. The only way I can think of doing this is to use the wpt http server to implement a counter, then have the JS code increment the counter, and register different things depending on the value of the counter.

@wabain
Copy link

@wabain wabain commented Mar 16, 2018

I gave this a try and it looks like fetch and xhr aren't exposed in worklet scope. Assuming that's by design, maybe I could add a debug option to expose a counter in the worklet scope?

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 16, 2018

Oh that's annoying. We could have the http server return a different JS program based on the counter it maintains? Otherwise, as you said, we could add a just-for-testing global counter (under the hood it would be something like a Arc<AtomicUsize>).

We could also use high-precision timers, and rely on the chance of two timers returning the same value as being vanishingly small.

@wabain
Copy link

@wabain wabain commented Mar 20, 2018

The module is only actually fetched from the server once, so unfortunately we can't vary the response. It would also be good to test some binary states (e.g. painter registered / not registered, alpha true / alpha false), and I don't know of a scheme that would give really strong odds of getting multiple outputs in those cases from timing information. I think it will have to be a test timer.

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 20, 2018

Oh that's annoying, our http cache is getting in the way :/

Probably the easiest thing is the timer then. or perhaps math.random()? Googling stack overflow for JS uuid gives: https://stackoverflow.com/a/2117523

@jdm jdm added the C-assigned label Mar 23, 2018
@jdm jdm added the C-has open PR label May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants
You can’t perform that action at this time.