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

> I would also prefer just one task. My understanding of the algorithm would be something like: queue a task that runs the following steps:
> 
>  * fire a focus event (taking stream, a subset of it, stream's clone...)

I don't see a problem with returning the original. Clones are trouble.

>  * execute focus algorithm based on focus policy computed from focus event handling.

I'd call it the "focus decision algorithm", since it doesn't seem necessary to specify when exactly actual focusing takes place.

>  * resolve getDisplayMedia promise with stream

Let's say I did this:
```js
async function getDisplayMedia() {
  const stream = await navigator.mediaDevices.getDisplayMedia();
  console.log("A");
  return stream;
}

const p = getDisplayMedia();
await new Promise(r => navigator.mediaDevices.onfocus = e => r(decide(stream) || e.preventDefault()));
console.log("B");
const stream = await p;
```
Would this produce `A B` or `B A`? I'm not sure microtask order here is even standardized.

> I do not see why we should delay the focus algorithm.

Tasks have cleaner semantics than messing with microtask order.

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


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

Received on Friday, 8 October 2021 21:28:24 UTC