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

Missing tasks in parallel steps in Handwriting Recognition API #35

Open
1 of 3 tasks
dontcallmedom-bot opened this issue Sep 9, 2024 · 3 comments
Open
1 of 3 tasks

Comments

@dontcallmedom-bot
Copy link

dontcallmedom-bot commented Sep 9, 2024

While crawling Handwriting Recognition API, the following algorithms fire an event, or resolve or reject a Promise, within a step that runs in parallel without first queuing a task:

  • The navigator-query-handwriting-recognizer algorithm resolves/rejects a promise directly in a step that runs in parallel
  • The navigator-create-handwriting-recognizer algorithm resolves/rejects a promise directly in a step that runs in parallel
  • The handwriting-drawing-get-prediction algorithm resolves/rejects a promise directly in a step that runs in parallel

See Dealing with the event loop in the HTML specification for guidance on how to deal with algorithm sections that run in parallel.

Cc @dontcallmedom @tidoust

This issue was detected and reported semi-automatically by Strudy based on data collected in webref.

@wacky6
Copy link
Member

wacky6 commented Sep 20, 2024

Hey @dontcallmedom, I've made a draft and have some questions:

  • Is there a guidance on which task source to use?
  • Do we need to explicitly call out the realm (in our case, it's always the realm of this)? Is the intention about "make sure every WebIDL objects is unambiguously associated with a realm"?

@tidoust
Copy link
Contributor

tidoust commented Sep 20, 2024

  • Is there a guidance on which task source to use?

Not really, see w3ctag/design-principles#38 for a discussion on this. Basic guideline is to create a dedicated task source for related events, so as to leave freedom to implementations to order these tasks relative to other (unrelated) tasks.

  • Do we need to explicitly call out the realm (in our case, it's always the realm of this)? Is the intention about "make sure every WebIDL objects is unambiguously associated with a realm"?

Yes. Specs such as DOM or HTML now include steps in their algorithms to initialize the realm and call it out in the call to "queue a global task", for example, see timeout(milliseconds). More specs now also do that to associate objects with realms more explicitly.

Calling things out has the advantage of removing all possible ambiguities. It also makes it easier to spot potential issues automatically (e.g., tasks where the realm is actually unclear). Now, from a readability perspective, it's certainly tempting to write a more generic "hey, the realm in the algorithms defined in this spec is always the same and unambiguous, so we won't repeat it everywhere".

A middle-ground approach that we're trying in the Presentation API is to define a wrapping queue a [custom] task algorithm that sets the parameters and calls "queue a global task" and that then gets used in the rest of the spec. The analysis tool will get lost for now because it does not yet follow algorithms, but hopefully it can become smart enough over time to understand this pattern.

@wacky6
Copy link
Member

wacky6 commented Sep 24, 2024

Thanks for the feedback, I've updated the draft :)

wacky6 added a commit that referenced this issue Nov 8, 2024
Updates in parallel steps for getPrediction() to follow recommendataions in #35

Co-authored-by: François Daoust <fd@tidoust.net>
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

No branches or pull requests

3 participants