- From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
- Date: Fri, 02 Sep 2022 23:46:02 +0000
- To: public-webrtc-logs@w3.org
After filing https://github.com/w3c/mediacapture-screen-share/issues/231 I fear that focusing after capture has begun adds some risk. This perhaps limits the attractiveness of a timer unless it's quite short. cc @martinthomson > > Would this unspecified behavior be identical to point 1? > > Unspecified is unspecified, but at least in Chrome's implementation, yes, that's what I intend. Good, we could still specify the invariant that it needs to be the _same_ behavior. > Do you suggest we only use a timer? Yes, that is all I proposed in the [OP](https://github.com/w3c/mediacapture-screen-share/issues/230#issue-1357941198). > If so, my problems with that include: > That seems like it's going to encourage Web-devs to produce buggy code that induces flaky behavior. Namely, they'll call setFocusBehavior() from a new task, see that it works on their machine, and fail to realize it flakes out 0.1% of the time on users' machines. As I [mentioned](https://github.com/w3c/mediacapture-screen-share/issues/230#issuecomment-1235915829) I question whether this is real. If my machine takes more than one second to run a task then it's too late to focus reliably anyway. I'd argue it becomes unsafe to focus then #231. > When the application fails to call setFocusBehavior() at all, the browser will be forced to wait N milliseconds before it performs its default behavior Not in my OP proposal. > > A microtask-sensitive promise-based API sounds terrible > > I hope we can agree that setFocusBehavior() itself will not return a Promise. > Or may I have misunderstood you on this particular point? If so, please clarify. getDisplayMedia returns a promise. See https://github.com/w3c/mediacapture-screen-share/issues/190#issuecomment-928242109. Microtasks are [fickle](https://jsfiddle.net/jib1/se57k0zw/): ```js const p = Promise.resolve(); function foo() { return p; } async function bar() { return p; } console.log(foo() === p); // true console.log(bar() === p); // false ``` E.g. simple stubs like this would FAIL, which seems unattractive: ```js async function gDM(constraints) { return navigator.mediaDevices.getDisplayMedia(constraints); } (async () => { const controller = new CaptureController(); const stream = await gDM({controller}); controller.setFocusBehavior("focus-captured-surface"); // throws })(); ``` > getCaptureHandle() is synchronous. Ok I misunderstood the requirements then. A callback approach avoids this. E.g.: ```js const controller = new CaptureController(); let stream; controller.pleaseFocus = () => stream.getCaptureHandle().origin == window.origin; stream = await navigator.mediaDevices.getDisplayMedia({controller}); ``` -- GitHub Notification of comment by jan-ivar Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/230#issuecomment-1235982999 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 2 September 2022 23:46:04 UTC