New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 829145 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Apr 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

navigator.vibrate() doesn't work on first tap (ontouchstart) and gives console error

Reported by redkata...@gmail.com, Apr 4 2018

Issue description

Chrome Version       : 66.0.3359.67 (Official Build) beta (32-bit)
URLs (if applicable) :
Other browsers tested:
  Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
     Safari:
    Firefox: OK 59.0.2
       Edge:

What steps will reproduce the problem?
(1) Create a page with a single <div ontouchstart='navigator.vibrate([150]);'>test vibrate</div>
(2) Tap the element
(3) Tap the element a second time

What is the expected result?
The phone/device will vibrate twice.


What happens instead?
The phone/device will only vibrate the second time (step 3).  The console also displays the error "[Intervention] Blocked call to navigator.vibrate because user hasn't tapped on the frame or any embedded frame yet: https://www.chromestatus.com/feature/5644273861001216"

 
Labels: Needs-Triage-M66
Labels: OS-Android
The issue seems to be related to OS-android. Hence, adding appropriate OS label.

Thanks...!!

Comment 3 by binlu@chromium.org, Apr 5 2018

Cc: -bi...@google.com binlu@chromium.org rbyers@chromium.org ojan@chromium.org
Status: WontFix (was: Unconfirmed)
This is work as intended since touchstart is not considered as user gesture any more (eg., mentioned here: https://www.chromestatus.com/feature/6131337345892352), but it works with the click event (try onclick).

+rbyers@chromium.org, ojan@chromium.org as FYI.
What if the first action a user takes is a long press on an element?  I'm trying to make the site act as much like an app as possible.

Comment 5 by binlu@chromium.org, Apr 5 2018

In that case, have you tried touchend? It should work according to https://www.chromestatus.com/feature/6131337345892352.
Yes, I have tried touchend, but the interaction people expect is not for the long press animation to start at the end of a touch but a second or so after long pressing.  For example, try holding down your finger on the android home screen.  The reaction from long pressing happens before you let go.  Every app and even iOS reacts the same way.

Comment 7 by binlu@chromium.org, Apr 5 2018

Cc: mustaq@chromium.org
Can you explain more about the use case that you have in mind? Like what kind of website you are building (eg., games or accessibility)? Why long press is preferred for vibrate triggering (instead of click)? 

+mustaq@chromium.org, who is working on user gesture refinement.
Labels: UserActivation
When uploading a file I have a single circular + button in the bottom right corner.  By default it will let you upload files, however I also want it to let you take a picture.  Instead of forcing people to tap the + button and then tap again to select the camera option, I'm trying to make it simpler... where you can long press the + button to select a different upload type (and it becomes the new default).
Another feature I was planning on adding is long pressing a photo to give extra options (such as to delete it). 
Thanks redkatana1@ for the explanation, but you didn't mention why vibrate is necessary and how it helps in your use case.
I'm not sure if I understand your question.  Isn't it the standard for long press action to be accompanied with a vibration?  Would you like me to provide examples of how apps and even the Android OS reacts to a user's long-press action and how it's accompanied by a vibration effect?  (Like, long pressing the quick actions in the notification tray is accompanied by a vibration)

If you're emphasizing the word "necessary", well then I'm not sure if you could argue anything is really necessary.  I'm just trying to provide an expected experience from a user action on a webpage - one that is globally used in every mobile device and OS.
I think the source of confusion here is the "touchstart" event: Android vibration happens only after a certain time, as if when the system has detected a long press (but not release).

To me, it seems like the "contextmenu" event could possibly be considered a user activation (or "user gesture") to solve your use case.  I am not sure at this moment why this event was excluded for so many years.  Anyone has any clue?
Thanks redkatana1@ for the explanation. I guess I don't use long press much on my phone.

Adding either the "contextmenu" event or "long press for 1-2 seconds" as user gesture sounds good to me for this use case.

>> why this event was excluded for so many years.  Anyone has any clue?
I guess the use case hasn't been come up quite often for mobile web?
I was wondering about "contextmenu" event on desktop (on right click) :(

This quarter we are planning to start working the set of events that "define" a user activation.  Let's discuss it in Issue 826293.

redkatana1@: to set the expectations right, Issue 826293 is going to be a tricky one for us since it would affect ~30 different APIs in Chrome (vibrate is just one of them).  So don't expect a solution soon!

We agreed that "touchstart" is not the right place to vibrate anyways, so let's leave this bug as "WontFix".
I did some testing and it appears as though adding contextmenu as a "user gesture" should be adequate for my use cases.
Thanks for confirming redkatana1@.

redkatana1@, good news: we just landed a change to support 'contextmenu' events, will be available in Chrome 68 ( Issue 836401 ).
Thank you! :)

Sign in to add a comment