Bug 93957

Summary: Clear pattern to prevent timing problem between cancelVibration and vibrate
Product: WebKit Reporter: Kihong Kwon <kihong.kwon>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: haraken, morrita, naginenis, vimff0, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Kihong Kwon 2012-08-14 04:48:58 PDT
If there is javascript codes like below,

navigator.vibrate(1000);
navigator.vibrate(0);

cancelVibrate() can be called before calling vibrate().(It's timer timing issue)
In this case, cancelVibrate() is not working at all.

We need to fix this.
Comment 1 Kihong Kwon 2012-08-14 05:22:28 PDT
Created attachment 158301 [details]
Patch
Comment 2 Kihong Kwon 2012-08-14 05:24:42 PDT
CC haraken and morrita.
Comment 3 Kentaro Hara 2012-08-14 05:26:17 PDT
Comment on attachment 158301 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=158301&action=review

> Source/WebCore/ChangeLog:11
> +        There is a timing issue in the cancelVibration.
> +        Since vibrate works based on timer, cancelVibration might be called
> +        eariler than vibrate when cancelVibration is called just after vibrate call.
> +        It can be prevented from clearing m_pattern in the cancelVibration.

Can't you write a layout test for this?
Comment 4 Kihong Kwon 2012-08-14 05:44:45 PDT
(In reply to comment #3)
> (From update of attachment 158301 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=158301&action=review
> 
> > Source/WebCore/ChangeLog:11
> > +        There is a timing issue in the cancelVibration.
> > +        Since vibrate works based on timer, cancelVibration might be called
> > +        eariler than vibrate when cancelVibration is called just after vibrate call.
> > +        It can be prevented from clearing m_pattern in the cancelVibration.
> 
> Can't you write a layout test for this?

There is no return value in the Vibration API.
Therefore, if we add layout test, I think we have only way to use printf like legacy notification tests.(LayoutTests/fast/notifications/)
But IMHO it's not good to us.
I would like to get your opinion about this please. :)
Comment 5 Kentaro Hara 2012-08-14 16:37:06 PDT
Comment on attachment 158301 [details]
Patch

Thanks, I understood that writing the test is difficult. The change looks reasonable, let's land it.
Comment 6 WebKit Review Bot 2012-08-14 17:10:51 PDT
Comment on attachment 158301 [details]
Patch

Clearing flags on attachment: 158301

Committed r125624: <http://trac.webkit.org/changeset/125624>
Comment 7 WebKit Review Bot 2012-08-14 17:10:56 PDT
All reviewed patches have been landed.  Closing bug.