Re: [mediacapture-screen-share] Conditional Focus (When Display-Capture Starts) (#190)

I wanted to clarify something about the fetch event and also ask a question.

The way fetch events work is basically:

1. Spec dispatches a fetch event.
2. This runs event listeners. As the user agent dispatched the event event, the microtask queue is drained here as well. (No JavaScript on the stack has that effect.)
3. Spec inspects state on the event.

This is a fairly normal pattern for event dispatching.

The problem with 2 in https://github.com/w3c/mediacapture-screen-share/issues/190#issuecomment-929625605 (queue a task) is that user interaction events might get in between and end up changing what the user wants to do. 1 seems rather surprising for web developers. At least the idea behind promises is that you can chain them a bunch with `then()`, even for what are normally synchronous tasks. This would end up invalidating that, which would be rather surprising I think.

My question is, did you consider passing a callback to `getUserMedia()` or dispatching an event to take care of this instead? That would give you a time-bound period that allows for custom logic and doesn't run into some of the issues you are facing. Failing that, I think 3 from @youennf's list could be an option. This would essentially require adding a step around 5/6 of https://html.spec.whatwg.org/#perform-a-microtask-checkpoint. It seems less elegant though.

Hope that helps.

-- 
GitHub Notification of comment by annevk
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/190#issuecomment-932093657 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 1 October 2021 10:03:18 UTC