{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/webrtc-pc/issues/307","labels_url":"https://api.github.com/repos/w3c/webrtc-pc/issues/307/labels{/name}","comments_url":"https://api.github.com/repos/w3c/webrtc-pc/issues/307/comments","events_url":"https://api.github.com/repos/w3c/webrtc-pc/issues/307/events","html_url":"https://github.com/w3c/webrtc-pc/pull/307","id":107565193,"number":307,"title":"Fix broken RTCPeerConnection's operations array to work with promises.","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,"milestone":null,"comments":16,"created_at":"2015-09-21T17:54:23Z","updated_at":"2015-09-23T18:56:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/w3c/webrtc-pc/pulls/307","html_url":"https://github.com/w3c/webrtc-pc/pull/307","diff_url":"https://github.com/w3c/webrtc-pc/pull/307.diff","patch_url":"https://github.com/w3c/webrtc-pc/pull/307.patch"},"body":"I'm resubmitting this PR for consideration as a solution to https://github.com/w3c/webrtc-pc/issues/299, and I respectfully request that people take another look, as I don't see any competing PRs to solve this issue."},"comment":{"url":"https://api.github.com/repos/w3c/webrtc-pc/issues/comments/142696674","html_url":"https://github.com/w3c/webrtc-pc/pull/307#issuecomment-142696674","issue_url":"https://api.github.com/repos/w3c/webrtc-pc/issues/307","id":142696674,"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":"2015-09-23T18:56:12Z","updated_at":"2015-09-23T18:56:12Z","body":"> ​What do you mean it executes it synchronously?\r\n\r\nEach of the five *operation*s: `createOffer`, `setLocalDescription`, `createAnswer`, `setRemoteDescription`, and `addIceCandidate`, are *functions* that come with processing models.\r\n\r\nLook at [`setLocalDescription`](http://w3c.github.io/webrtc-pc/#widl-RTCPeerConnection-setLocalDescription-Promise-void--RTCSessionDescription-description):\r\n> 1. Let *p* be a new promise.\r\n> 2. If this RTCPeerConnection object's signaling state is closed, the user agent MUST reject p with InvalidStateError, and jump to the step labeled Return.\r\n> 3. If a local description contains a different set of ICE credentials, then the ICE Agent MUST trigger an ICE restart. When ICE restarts, the gathering state will be changed back to \"gathering\", if it was not already gathering. If the RTCPeerConnection ice connection state was \"completed\", it will be changed back to \"connected\".\r\n> 4. The user agent MUST start the process to apply the RTCSessionDescription argument.\r\n> 5. Return: Return *p*.\r\n\r\n(I'm leaving out the remaining steps which are all about what step 4 launched in parallel).\r\n\r\nBefore it returns, this function:\r\n1. Creates a new promise *p*.\r\n2. Rejects and returns *p* if the pc is closed.\r\n3. Starts stuff in parallel that will resolve or reject *p* later.\r\n4. Returns *p*.\r\n\r\n\r\n*p* is important, as without *p* you have no handle on when the asynchronous part set up by `setLocalDescription` completes.\r\n\r\n*Without calling these steps you have no p*. Furthermore, in the typical call (where nothing is queued) the steps must be called *synchronously*, by which I mean that the steps must have executed *before* the call from content JS returns, and *p* must be returned to content JS.\r\n\r\nThat's what I mean by synchronous."}}