Bug 130059 - Refactor Vibration algorithm to use only one timer.
Summary: Refactor Vibration algorithm to use only one timer.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 129598 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-03-10 18:12 PDT by Jinwoo Jeong
Modified: 2014-03-13 20:51 PDT (History)
9 users (show)

See Also:


Attachments
Patch (10.54 KB, patch)
2014-03-10 18:34 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff
Patch (10.75 KB, patch)
2014-03-11 01:49 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff
Patch (10.69 KB, patch)
2014-03-11 22:54 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff
Patch (10.66 KB, patch)
2014-03-11 23:03 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff
Patch (10.66 KB, patch)
2014-03-13 18:24 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff
Patch (10.65 KB, patch)
2014-03-13 18:28 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jinwoo Jeong 2014-03-10 18:12:44 PDT
Currently Vibration has used two timers,
But they does not work in same time.
And in Vibration, there are some difference between algorithm defined in specification and implementation.
Comment 1 Jinwoo Jeong 2014-03-10 18:34:16 PDT
Created attachment 226363 [details]
Patch
Comment 2 Jinwoo Song 2014-03-10 19:29:59 PDT
Comment on attachment 226363 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        Refactor Vibration algorithm to use only 1 timer.

nit: s/1/one

> Source/WebCore/ChangeLog:8
> +        Currently Vibration has used 2 timer,

Writing suggestion: 'Currently Vibration is using two timers,'

> Source/WebCore/ChangeLog:13
> +        Indeed this patch applies the algorithm and restrictions defined on specification.

Writing suggestion: 'Also, this patch implement the missing part of the algorithm, which check the maximum length of the vibration pattern and the maximum duration of the vibration.

> Source/WebCore/Modules/vibration/Vibration.cpp:32
> +const unsigned MaxVibrationDuration = 10000;

Where these magic values come from?

> Source/WebCore/Modules/vibration/Vibration.cpp:87
>          return true;

These lines can be removed as it is already checked.

> Source/WebCore/Modules/vibration/Vibration.cpp:110
> +        m_state = Idle;

You may return here.

> Source/WebCore/Modules/vibration/Vibration.cpp:111
> +    else {

Why don't you use switch-case statement here?

> Source/WebCore/Modules/vibration/Vibration.h:-45
> -    // FIXME : Add suspendVibration() and resumeVibration() to the page visibility feature, when the document.hidden attribute is changed.

It's okay to remove these unused methods but It would be better to comment 'FIXME' for implementing page visibility feature.
Comment 3 Darin Adler 2014-03-11 00:32:33 PDT
Comment on attachment 226363 [details]
Patch

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

> Source/WebCore/Modules/vibration/Vibration.cpp:72
> +    for (size_t i = 0; i < length; ++i) {
> +        if (sanitized[i] > MaxVibrationDuration)
> +            sanitized[i] = MaxVibrationDuration;
> +    }

I suggest writing it like this:

    for (auto& duration : sanitized)
        duration = std::min(duration, MaxVibrationDuration);
Comment 4 Jinwoo Jeong 2014-03-11 01:28:40 PDT
> > Source/WebCore/Modules/vibration/Vibration.cpp:32
> > +const unsigned MaxVibrationDuration = 10000;
> 
> Where these magic values come from?
I referred to blink.

And others is done.
Comment 5 Jinwoo Jeong 2014-03-11 01:49:17 PDT
Created attachment 226397 [details]
Patch
Comment 6 Jinwoo Jeong 2014-03-11 22:54:52 PDT
Created attachment 226476 [details]
Patch
Comment 7 Jinwoo Jeong 2014-03-11 23:03:43 PDT
Created attachment 226477 [details]
Patch
Comment 8 Darin Adler 2014-03-13 10:56:27 PDT
Comment on attachment 226477 [details]
Patch

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

> Source/WebCore/Modules/vibration/Vibration.cpp:72
> +    // Pre-exsiting instance need to be canceled when vibrate() is called.

Typo: "exsiting".

> Source/WebCore/Modules/vibration/Vibration.h:43
> +    // FIXME : When visibilitychange event is dispatched, if a vibration is working, it should be canceled.

No space before the ":" in "FIXME:".

I don’t understand the meaning of the phrase “a vibration is working”.

> Source/WebCore/Modules/vibration/Vibration.h:58
> +    enum class State {
> +        Idle,
> +        Vibrating,
> +        Waiting
> +    };

I’d suggest putting this on a single line instead of 5 lines.
Comment 9 Jinwoo Jeong 2014-03-13 18:24:33 PDT
Created attachment 226636 [details]
Patch
Comment 10 Jinwoo Jeong 2014-03-13 18:28:57 PDT
Created attachment 226637 [details]
Patch
Comment 11 Jinwoo Jeong 2014-03-13 18:37:52 PDT
(In reply to comment #8)
> (From update of attachment 226477 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=226477&action=review
> 
> > Source/WebCore/Modules/vibration/Vibration.cpp:72
> > +    // Pre-exsiting instance need to be canceled when vibrate() is called.
> 
> Typo: "exsiting".
> 
> > Source/WebCore/Modules/vibration/Vibration.h:43
> > +    // FIXME : When visibilitychange event is dispatched, if a vibration is working, it should be canceled.
> 
> No space before the ":" in "FIXME:".
> 
> I don’t understand the meaning of the phrase “a vibration is working”.
> 
> > Source/WebCore/Modules/vibration/Vibration.h:58
> > +    enum class State {
> > +        Idle,
> > +        Vibrating,
> > +        Waiting
> > +    };
> 
> I’d suggest putting this on a single line instead of 5 lines.


Applied Darin's comment.
Comment 12 WebKit Commit Bot 2014-03-13 19:50:25 PDT
Comment on attachment 226637 [details]
Patch

Clearing flags on attachment: 226637

Committed r165598: <http://trac.webkit.org/changeset/165598>
Comment 13 WebKit Commit Bot 2014-03-13 19:50:32 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 8179.jeong@gmail.com 2014-03-13 20:51:53 PDT
*** Bug 129598 has been marked as a duplicate of this bug. ***