{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/mediacapture-record/issues/54","repository_url":"https://api.github.com/repos/w3c/mediacapture-record","labels_url":"https://api.github.com/repos/w3c/mediacapture-record/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/w3c/mediacapture-record/issues/54/comments","events_url":"https://api.github.com/repos/w3c/mediacapture-record/issues/54/events","html_url":"https://github.com/w3c/mediacapture-record/issues/54","id":148414726,"number":54,"title":"Async algorithms .start(), .stop(). pause() et al. need major work","user":{"login":"jan-ivar","id":3136226,"avatar_url":"https://avatars.githubusercontent.com/u/3136226?v=3","gravatar_id":"","url":"https://api.github.com/users/jan-ivar","html_url":"https://github.com/jan-ivar","followers_url":"https://api.github.com/users/jan-ivar/followers","following_url":"https://api.github.com/users/jan-ivar/following{/other_user}","gists_url":"https://api.github.com/users/jan-ivar/gists{/gist_id}","starred_url":"https://api.github.com/users/jan-ivar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jan-ivar/subscriptions","organizations_url":"https://api.github.com/users/jan-ivar/orgs","repos_url":"https://api.github.com/users/jan-ivar/repos","events_url":"https://api.github.com/users/jan-ivar/events{/privacy}","received_events_url":"https://api.github.com/users/jan-ivar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-04-14T16:23:34Z","updated_at":"2016-11-01T21:23:59Z","closed_at":null,"body":"The fundamental design of async algorithms should be:\n1. You do some stuff synchronously up front to make sure the API call makes sense, and throw if not.\n2. You return.\n3. You do async stuff like waiting, fetching, etc. [_in parallel_](https://html.spec.whatwg.org/#in-parallel).\n4. Any further communication with your original caller happens from tasks you post to a task source.\n\nCompare this to the `.start()` algorithm (and most of the others):\n1. Queues a task immediately on the _DOM manipulation task source_ (effectively the main thread!).\n2. It never returns.\n3. It throws exceptions from a queued task, which never make it back to content.\n4. It blocks the main thread with language like \"wait until media becomes available\".\n5. It fires events like `stop` synchronously from code that seems asynchronous, causing JS concurrency.\n\nI suspect all the algorithms that queue to _DOM manipulation task source_ and then wait should be rewritten this way. Some like `.resume()` may be fine as-is, though I'm curious why we seem to prefer changing state on the next event loop rather than synchronously?\n"},"comment":{"url":"https://api.github.com/repos/w3c/mediacapture-record/issues/comments/257702481","html_url":"https://github.com/w3c/mediacapture-record/issues/54#issuecomment-257702481","issue_url":"https://api.github.com/repos/w3c/mediacapture-record/issues/54","id":257702481,"user":{"login":"jan-ivar","id":3136226,"avatar_url":"https://avatars.githubusercontent.com/u/3136226?v=3","gravatar_id":"","url":"https://api.github.com/users/jan-ivar","html_url":"https://github.com/jan-ivar","followers_url":"https://api.github.com/users/jan-ivar/followers","following_url":"https://api.github.com/users/jan-ivar/following{/other_user}","gists_url":"https://api.github.com/users/jan-ivar/gists{/gist_id}","starred_url":"https://api.github.com/users/jan-ivar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jan-ivar/subscriptions","organizations_url":"https://api.github.com/users/jan-ivar/orgs","repos_url":"https://api.github.com/users/jan-ivar/repos","events_url":"https://api.github.com/users/jan-ivar/events{/privacy}","received_events_url":"https://api.github.com/users/jan-ivar/received_events","type":"User","site_admin":false},"created_at":"2016-11-01T21:23:59Z","updated_at":"2016-11-01T21:23:59Z","body":"@miguelao These still need to be addressed. See my review comments in https://github.com/w3c/mediacapture-record/pull/83 for details."}}
{"actor":{"display_login":"jan-ivar"}}