Re: Vibration: throwing and pause

Le 13/04/2013 10:24, Anne van Kesteren a écrit :
> On Fri, Apr 12, 2013 at 9:57 PM, Justin Lebar <justin.lebar@gmail.com> wrote:
>> The method is definitely not intended to be synchronous in Firefox's
>> implementation.
>>
>> I don't even know what it means to synchronously do an operation like this.
>> Obviously the vibrate() call doesn't block until the phone starts
>> moving, or something like that.
>>
>> Could you elaborate on how making this method sync and spinning the event loop
>> impacts content authors?  I agree with Anne that making this sync seems Very
>> Bad.
> Yeah, it should simply return early and then asynchronously do the
> vibration bits.
The API itself doesn't make this straightforward, but that's what it 
does. I recommend reading the thread starting at [1] as some points 
overlap with this thread.

To summarize what happened on the linked thread:
* The vibration API is "fire-and-forget" style, that is you call 
vibrate(), it returns as soon as possible and does the vibration in 
parallel of the rest of script execution.
This behavior is apparently also the one on Android [4]. This would be 
related to the hardware API itself which forces programming to this 
style. I don't remember from this thread whether someone showed some 
proof that hardware really forces this or even will always be like this, 
but that's apparently what we have.
I would love to read from someone with mobile hardware expertise whether 
the API exposed by the hardware is or could be any different.
* I wished (and still wish) for the maximum vibration time to be exposed 
as part of the API [2]. This info can be discovered by a script anyway, 
but requires a hack that may result in poor UX [3]

Hope that helps :-)

David

[1] http://lists.w3.org/Archives/Public/public-device-apis/2012Nov/0003.html
[2] http://lists.w3.org/Archives/Public/public-device-apis/2012Nov/0027.html
[3] https://gist.github.com/DavidBruant/4066406
[4] http://lists.w3.org/Archives/Public/public-device-apis/2012Nov/0007.html

Received on Sunday, 14 April 2013 12:43:47 UTC