Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. #4221

Closed
jvbianchi opened this issue Apr 22, 2017 · 33 comments · Fixed by #4947
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@jvbianchi
Copy link

jvbianchi commented Apr 22, 2017

Bug, feature request, or proposal:

In chrome 58, warnings started appearing on console:

zone.min.js:1 [Violation] 'readystatechange' handler took 190ms
zone.min.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive.
zone.min.js:1 [Violation] 'load' handler took 517ms

What is the expected behavior?

Don't get this warning on console:
screen shot 2017-04-22 at 20 02 47

What are the steps to reproduce?

Just running the template plunker you get this console warning.
Console must be in the verbose level

Plunker: https://goo.gl/DlHd6U

Which versions of Angular, Material, OS, browsers are affected?

Chrome 58.0.3029.81
Mac OSX 10.12.4 (Sierra)

@jelbourn jelbourn added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Apr 24, 2017
@jackvial
Copy link

jackvial commented May 8, 2017

Looks like it's related to the new event listener options. More on it here and here

There is no a new options object that can be passed to the addEventListener. The warning is saying the passive event listeners on the page should be passed the {passive: true} option to improve scroll performance. document.addEventListener('touchstart', handler, {passive: true});.

These warnings are only performance recommendation so it's not really something to get too worried about, although performances improvements are always good.

@tarlepp
Copy link

tarlepp commented May 9, 2017

Using https://github.com/zzarcon/default-passive-events will remove some of those violation warnings, but there is still some left.

crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 3, 2017
Removes an unnecessary `touchstart` listener on the button toggle. It was initially added to prevent it from capturing user events, however it's no longer necessary, because we have `pointer-events: none` on the element. This also fixes a warning that is being logged by Chrome.

Fixes angular#4221.
@crisbeto crisbeto added the has pr label Jun 3, 2017
andrewseguin pushed a commit that referenced this issue Jun 8, 2017
)

Removes an unnecessary `touchstart` listener on the button toggle. It was initially added to prevent it from capturing user events, however it's no longer necessary, because we have `pointer-events: none` on the element. This also fixes a warning that is being logged by Chrome.

Fixes #4221.
@acronHou
Copy link

acronHou commented Sep 4, 2017

what about "bind"?

@Zwilla
Copy link

Zwilla commented Oct 4, 2017

I can not understand why this is closed, the problem always exist and only this:
https://github.com/zzarcon/default-passive-events
solved my problem, the above problem
thx to @tarlepp

@Dunos
Copy link

Dunos commented Oct 10, 2017

Yup, can confirm that this is still happening

@FredvanRijswijk
Copy link

Yes still getting this warning:

zone.js:1666 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive.

@mackelito
Copy link

@andrewseguin are there any recommended solutions for this issue?

@micahwood
Copy link

micahwood commented Oct 11, 2017

This seems to have gotten worse with beta 12. Displaying a dialog used to appear instantly, now it takes close to 2 seconds for the dialog to appear.
[Violation] 'click' handler took 1690ms

The following message is logged about 1200 times from the time I click the button to display a dialog and it appearing. On Material beta 11 it was not logged at all while displaying the dialog.
[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive.

It looks my specific issue is being caused by a mat-autocomplete with a large data set. I'll create a plunker to demonstrate it.

@micahwood
Copy link

Here is a plunker showing the issue with slowing down substantially with large data sets. I added a button to display the autocomplete to make it easier to see the slow down. Also if you open the dev tools and set logging to verbose you can see how many event listeners are being created. It looks like it creates two listeners for each item that is added. I will create a new issue for this.
https://plnkr.co/edit/QhlHy7FrlvQbDeRfncCo?p=preview

@crisbeto
Copy link
Member

FWIW, those touchstart handlers were added to accommodate the ripple effect on buttons. They have since been removed because they were problematic.

@tarlepp
Copy link

tarlepp commented Oct 13, 2017

this is still happening, should we create a new issue about this, because this one is "closed" when it really isn't resolved at anyway ?

Or @casesandberg did you close this issue by mistake ?

@joshwiens
Copy link
Contributor

joshwiens commented Oct 19, 2017

@tarlepp - This should be resolved with #7557 ( doesn't happen on master ) so it should just be a matter of waiting on the next tag or running on a nightly build if it's absolutely critical.

@debslord
Copy link

debslord commented Nov 3, 2017

Thanks @d3viant0ne do you know when this is likely to be released?

I'm getting a lot of [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' events appearing in the console and my forms are really slow to load.... It reports back that
[Violation] 'click' handler took 17807ms

Keeping my fingers crossed that #7557 resolves these issues!

@joshwiens
Copy link
Contributor

joshwiens commented Nov 3, 2017

I'm running on "@angular/material": "git+https://github.com/angular/material2-builds#2.0.0-beta.12-62b149f", & the associated CDK & the problem no longer exists.

That build is stable & works with Angular 5.x, at least within the scope of what I am doing. material2-builds are static if you target the hash, really no different than a published build in the strictest sense.

@debslord
Copy link

debslord commented Nov 6, 2017

Thanks again @d3viant0ne

Upgraded my project to Angular 5 and the build you're on - weirdly still an issue for me.

This occurs 8000+ times - [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event.
[Violation] 'click' handler took 18268ms
[Violation] 'load' handler took 477ms

As a result the form takes around 20 seconds to load - same as @micahwood plunker as he said the larger the dataset the more event listeners

@joshwiens
Copy link
Contributor

@debslord - I'll take another look with the filters off. 90% sure the touchstart stuff is no longer an issue ( on my side at least )

@debslord
Copy link

debslord commented Nov 6, 2017

Thank you! I will see about implementing default-passive-events I might have to result to that fix instead

@debslord
Copy link

debslord commented Nov 7, 2017

I think my issues are probably more around the autocomplete issues mentioned in #5113 and #7749
So it might be slightly different to the issues you were getting @d3viant0ne

Implementing default-passive-events doesn't work either as there seems to be an issue around click events already having this set by default and so it throws an error instead and although the toughstart issues aren't displayed in the console the click still takes much too long. I'm hoping the other two issues will resolve this. Thanks for you help.

@lexyfeito
Copy link

Please when is this going to be fixed, this is slowing down my app's performance like crazy. Thank you

@vegarda
Copy link

vegarda commented Dec 6, 2017

This is back in 5.0.0-rc.3(?)

@olaf89
Copy link

olaf89 commented Dec 6, 2017

I have same issues with 5.0.0-rc.3

@crisbeto
Copy link
Member

crisbeto commented Dec 6, 2017

It should be fixed by #8719.

@lexyfeito
Copy link

@crisbeto which release will this be in?

@gyx8899
Copy link

gyx8899 commented Dec 14, 2017

I find one solution to solve this warning. (It works fine for me)

Added-non-passive-event-listener-to-a-scroll-blocking-touchstart-event-Consider-marking-event-handler-as-passive-to-make-the-page-more-responsive-by-visionfortech

jQuery.event.special.touchstart = { setup: function( _, ns, handle ){ if ( ns.includes("noPreventDefault") ) { this.addEventListener("touchstart", handle, { passive: false }); } else { this.addEventListener("touchstart", handle, { passive: true }); } } };

@fertandil87
Copy link

it's fixed in 5.0.0-rc.2, and appear again in ">= 5.0.0-rc.3"

@surbhi290391
Copy link

i am facing this same issue in recaptcha_en.js s can anyone tell me ow can i enable passive=true for recaptcha

wettenhj added a commit to wettenhj/mytardis that referenced this issue Jul 24, 2018
console warnings from angular-material.
Described here: angular/components#4221
We are using https://github.com/angular/material/ (the AngularJS 1.x version)
for My Publications.

Updating AngularJS dependency versions slightly.
wettenhj added a commit to wettenhj/mytardis that referenced this issue Aug 5, 2018
console warnings from angular-material.
Described here: angular/components#4221
We are using https://github.com/angular/material/ (the AngularJS 1.x version)
for My Publications.

Updating AngularJS dependency versions slightly.
@phil123456
Copy link

sept 2018 and still hapenning
angular: ^5.2.0
ng CLI: ~1.7.4
tslint: ~5.9.1
typescript: ~2.5.3
webpack: ~3.11.0

@crisbeto
Copy link
Member

@phil123456 which Material components are you using on the page that is logging out the warning?

@phil123456
Copy link

sorry I did not realize it was "material" project

@brecko
Copy link

brecko commented Nov 2, 2018

I was having the same issue. It turned out to be the Chrome Extension 'Logitech Smooth Scrolling'. When I turned it off, I no longer saw the violations in my Angular 6 Material app.

@krokofant
Copy link

The default-passive-events workaround is horrible, it messes up the available functionality of existing or future eventhandlers that want to preventDefault() an event.

@Gonzo2O28
Copy link

Any updates on this issue?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.