- From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
- Date: Mon, 27 Sep 2021 20:23:08 +0000
- To: public-webrtc-logs@w3.org
> All promise composition is allowed, including shims, `try`/`catch()`, breaking things into async sub-functions, `Promise.resolve(p)` and `Promise.race(p, timeout)`. This I claim is POLA.
In contrast, here's a list of benign things that'd cause action-at-a-distance focus-failure we go with a microtask cutoff:
1. getDisplayMedia [shimming](https://github.com/w3c/mediacapture-screen-share/issues/190#issuecomment-926852042) with any post-success code at all
2. Promise-branching like @youennf's getDisplayMedia [shimming workaround](https://github.com/w3c/mediacapture-screen-share/issues/190#issuecomment-928099217) won't work either
3. Putting gDM into a [sub function](https://github.com/w3c/mediacapture-screen-share/issues/190#issuecomment-926852042) with any post-success code at all
4. Try-catch in a sub-function or shim
```js
async function getDisplayMedia(c) {
try {
await navigator.mediaDevices.getDisplayMedia(c); // microtask checkpoint
} catch (e) {
log.addTo(e); // log all gDM errors
throw e;
}
}
```
5. Promise.resolve()
```js
function foo(mediaDevices) {
return Promise.resolve(mediaDevices?.getDisplayMedia(c)); // microtask checkpoint
}
```
6. Application timeout
```js
const wait = ms => new Promise(r => setTimeout(r, ms));
function timeout(p, ms) {
return Promise.race([p, wait(ms)]); // microtask checkpoint
}
await timeout(navigator.mediaDevices.getDisplayMedia(c), 10000); // 10s timeout
```
--
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/190#issuecomment-928242109 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 27 September 2021 20:23:10 UTC