New issue
Advanced search Search tips

Issue 784027 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome , Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

addEventListener is very slow for touch events

Reported by roblour...@gmail.com, Nov 11 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Steps to reproduce the problem:
Call addEventListener with touchstart, touchend, or touchmove - it's much slower than calling it for a touch event.

Use the test script - it calls addEventListener 100 times with either the touch events or the mouse events. Calling for the touch events are always much slower. On my machine, typically around .5ms to run the mouse event test, and up to 20ms to run the touch event test.

What is the expected behavior?
They should both be fast. They are the same speed in FF.

What went wrong?
Screenshot shows the actual timings.

Did this work before? Yes It broke somewhere between Chrome 56 and 58. Still broken in canary 64

Does this work in other browsers? Yes

Chrome version: 61.0.3163.100  Channel: n/a
OS Version: OS X 10.12.6
Flash Version:
 
index.html
1.2 KB View Download
Screen Shot 2017-11-10 at 5.26.40 PM.png
32.5 KB View Download

Comment 1 by phistuck@gmail.com, Nov 11 2017

Looks like the DOM operation might also be affected, because when you only add event listeners to window, it is much better and the difference is less severe -
a=performance.now(); for (i=0; i<1000;i++) { addEventListener("touchstart", function () {}); addEventListener("touchmove", function () {}); addEventListener("touchend", function () {}); } b=performance.now(); console.log(a,b,b-a);

a=performance.now(); for (i=0; i<1000;i++) { addEventListener("mousedown", function () {}); addEventListener("mousemove", function () {}); addEventListener("mouseup", function () {}); } b=performance.now(); console.log(a,b,b-a);
// 222926.515 222960.65000000002 34.13500000000931
// 222961.33500000002 222980.545 19.20999999999185

Comment 2 by phistuck@gmail.com, Nov 11 2017

Well, "better" was a strong word. :) It was better for touch, but mouse got significantly worse.
Components: Blink>Input
Labels: Hotlist-Input-Dev
Owner: dtapu...@chromium.org
Status: Assigned (was: Unconfirmed)
Components: -Blink>Input Blink>PerformanceAPIs
If I remove the lines in the block that log the performance violation all is much faster (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/events/EventTarget.cpp?type=cs&q=%22Consider+marking+event+handler+as%22&sq=package:chromium&l=304)

Seems the slowness all comes from logging the performance violation. Over to the performance api team to determine whether this is fast enough and this issue should be closed.


Owner: ----
Status: Untriaged (was: Assigned)
Owner: pfeldman@chromium.org
Status: Assigned (was: Untriaged)
Pavel, does this match the performance characteristics you'd expect from  PerformanceMonitor::ReportGenericViolation?
Owner: kozy@chromium.org
Unfortunately, it does, but only in case DevTools are open. https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/frame/PerformanceMonitor.cpp?sq=package:chromium&l=356 is capturing the stack to point at the offender.

@kozy: capturing 100 stacks at the same location takes 11ms, this sounds slow given your recent improvements on the stack capturing front.

Comment 8 by dproy@chromium.org, Apr 9 2018

100 day ping: Any update on this bug? 
Ping again. Any update?
Labels: OS-Chrome
100 day ping: Has there been any progress here? FWIW, the index.html file from #1 is still showing ~0.5 ms for mouse events and 20-40 ms for touch events on 71.0.3578.21 on my pixelbook...

Sign in to add a comment