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

Re: Question about sync / async for createOffer and createAnswer

From: Eric Rescorla <ekr@rtfm.com>
Date: Wed, 9 May 2012 11:22:35 -0700
Message-ID: <CABcZeBOjfxDs03Gpv4GLePJyn_MtwRA4aNi44bxTCh8odOWGvA@mail.gmail.com>
To: Martin Thomson <martin.thomson@gmail.com>
Cc: Cullen Jennings <fluffy@cisco.com>, public-webrtc@w3.org, Justin Uberti <juberti@google.com>, Adam Bergkvist <adam.bergkvist@ericsson.com>
On Wed, May 9, 2012 at 10:23 AM, Martin Thomson
<martin.thomson@gmail.com> wrote:
> +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.

Hmm... I'd be generally not thrilled if my implementation didn't guarantee
that caling setLocalDescription() in the callback didn't succeed, modulo
some sort of emergency condition. Makes it hard to write the JS code...

Received on Wednesday, 9 May 2012 18:23:48 UTC

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