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 09:44:14 -0700
Message-ID: <CABcZeBM3GhXT5RxtoTapT_=pGuNSjad1VX9xYMN8EEXrqg9bxA@mail.gmail.com>
To: Cullen Jennings <fluffy@cisco.com>
Cc: public-webrtc@w3.org, Justin Uberti <juberti@google.com>, Adam Bergkvist <adam.bergkvist@ericsson.com>
On Wed, May 9, 2012 at 8:07 AM, Cullen Jennings <fluffy@cisco.com> wrote:
>
> It is clear that in some cases it might take a bit of time to generate the
> offer in cases where operating system resources, particularly hardware
> codecs, needed to be acquired. However, if this can happen quickly, then
> there is no need for async call. The questions is how quickly can this
> happen and how quick is quick enough. We have two proposal sync, and async.
>
>
> Sync proposal:
>
> The proposal would be createOffer, and createAnswer, and synchronous and
> must return in less than 100 ms. Some poking around shows there are devices
> that would likely take around that amount of time to allocate resources. We
> have a few questions on this
>
> 1) is this long enough or do some devices needed more time?
>
> We are particularly interested in information from mobile devices and
> devices where the DSP are separate from the main CPU.
>
> 2) is 100 ms too long for the JS execution to be blocked?
>
> From initial conversations with a few folks it seems like that might be the
> cased but we would like to get more feedback on this. If it is, too long,
> then we likely need to the async proposal.

This isn't my area, but I asked Adam Barth, one of the WebKit maintainers
and he says that 100ms is way too long to block the thread. He says
his benchmark for when something needs async is 60Hz.

-Ekr

>
> Async Proposal
>
> The create offer would take a function something like
>
> pc.createOffer(function (offer) {
>   offer = tweakOffer(offer);
>   pc.setLocalDescription("offer", offer);
>   // ...
> }, hints);
>
> The questions here is
>
> 3) does this look like an OK way to do the async version ?
>
> Whatever we do to createOffer, we will do the corresponding thing to
> createAnswer.

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);
Received on Wednesday, 9 May 2012 16:45:30 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:28 UTC