Re: Question about sync / async for createOffer and createAnswer

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...

-Ekr

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