Bug 93957 - Clear pattern to prevent timing problem between cancelVibration and vibrate
Summary: Clear pattern to prevent timing problem between cancelVibration and vibrate
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-14 04:48 PDT by Kihong Kwon
Modified: 2012-08-14 17:10 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.54 KB, patch)
2012-08-14 05:22 PDT, Kihong Kwon
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.