W3C home > Mailing lists > Public > public-webrtc@w3.org > May 2012

Re: Question about sync / async for createOffer and createAnswer

From: Martin Thomson <martin.thomson@gmail.com>
Date: Wed, 9 May 2012 10:23:14 -0700
Message-ID: <CABkgnnVVZ4X_4tkwgA7hOces3KzX7xSaCoK_ZZ9kw_4sdQmNfA@mail.gmail.com>
To: Eric Rescorla <ekr@rtfm.com>
Cc: Cullen Jennings <fluffy@cisco.com>, public-webrtc@w3.org, Justin Uberti <juberti@google.com>, Adam Bergkvist <adam.bergkvist@ericsson.com>
+1 for async, and async always.

On 9 May 2012 09:44, Eric Rescorla <ekr@rtfm.com> wrote:
> Do I have to call setLocalDescription() from the callback? I.e., is this
> acceptable:
> pc.createOffer(function (offer) {
>   offer = tweakOffer(offer);
>   setTimeout(function() {
>      pc.setLocalDescription("offer", offer);
>      }, 1000);
>   // ...
>   }, hints);

Damn, I hope so.  This should be just a blob of data, and who knows
what you might need to do to "tweak" the offer.  Maybe you have that
logic on a server somewhere.

The only concern is if the conditions have changed in such a way that
the offer is available for a strictly limited time.  I suspect however
that this is always the case and setLocalDescription can fail, even
with an immediate call with unmodified offer.  If it takes 100ms to
get the info, some of the info could be up to that old when it
arrives, giving a 100ms window for stuff to happen (other tabs to grab
the camera, user to revoke permissions, etc...).  createOffer doesn't
create any commitment after all.

Received on Wednesday, 9 May 2012 17:23:46 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:17:27 UTC