You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive.
[Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.
16:29:39.142
My approach to solve this problem was add event on didInsertElement and remove them on willDestroyElement lifecycle functions, setting {passive: true} as last parameter when adding the event listener:
@filipe-torres this is essentially what {{on}} does, and we highly recommend you use the modifier over component lifecycle hooks, since those no longer exist in the Octane programming model.
What we need is an RFC that is exactly like emberjs/rfcs#486 but for these events. For reference, I think that the work that @simonihmig did implementation wise in #18214 is exactly what we need to do...
What we need is an RFC that is exactly like emberjs/rfcs#486 but for these events
The events in that RFC were a bit tricky as they were non-bubbling events that as such don't play well with EventDispatcher's event delegation approach and as such were harder to support. But touchstart, touchmove and whatever other events might be related to this issue don't have this problem. Rather the issue here is that (non-passive) event listeners are attached eagerly, even if those events are not actually used in Ember components.
So, @rwjblue what do you think about not deprecating these, but rather attaching event listeners lazily only when those events are actually used, i.e. reviving your previous work in #17911?
I would guess that this could practically solve the problem here, as in ~99% of apps (my own wild guess), the offending events are not used (at least in that old Ember.Component event method way). And if they are used in the app, you can easily rewrite the usage to attach event listeners manually (similar to RFC486's transition path) - which would enable the lazy approach to not attach non-passive event listeners.
Activity
[-]Passive Listener Violation[/-][+]Passive Listener Violation In Chrome[/+]evanaj commentedon May 26, 2017
I faced the same issue. How can I solve it?
wellington1993 commentedon Jun 9, 2017
I have the same problem:
[Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.
16:29:39.142
wellington1993 commentedon Jun 9, 2017
Is it a related question: #12783 ???
krisselden commentedon Jun 9, 2017
@wellington1993 you can remove events via https://emberjs.com/api/classes/Ember.Application.html#property_customEvents and if your app needs these events use passive listeners for mousewheel, touchstart, touchmove (only events that can block scroll via preventDefault matter for passive listening), you add on didInsertElement and remove on willDestroyElement of a component.
pixelhandler commentedon Sep 14, 2018
@evanaj @krisselden @stefanpenner @wellington1993 is this still an issue, perhaps we should close; what do you think?
btecu commentedon Jan 31, 2019
@pixelhandler this is still an issue with the latest version:

st-h commentedon Aug 21, 2019
It seems that ember >= 3.11 now provides a way to add passive event listeners via the
onmodifier: https://blog.emberjs.com/2019/07/15/ember-3-11-released.htmlrwjblue commentedon Aug 22, 2019
Confirm, though it doesn't yet avoid adding the non-passive listener to
body(really therootElement).filipe-torres commentedon Oct 11, 2019
My approach to solve this problem was add event on didInsertElement and remove them on willDestroyElement lifecycle functions, setting {passive: true} as last parameter when adding the event listener:
pzuraq commentedon Oct 11, 2019
@filipe-torres this is essentially what
{{on}}does, and we highly recommend you use the modifier over component lifecycle hooks, since those no longer exist in the Octane programming model.fix passive listener violations in chrome
chore: fix deprecations and warnings in tests (#1127)
Disable global, non-passive `touchstart` and `touchmove` event listeners
Auto merge of #2385 - Turbo87:non-passive, r=locks
rwjblue commentedon Oct 16, 2020
We need to figure out the canonical list of events that issue this warning.
Some additional references:
What we need is an RFC that is exactly like emberjs/rfcs#486 but for these events. For reference, I think that the work that @simonihmig did implementation wise in #18214 is exactly what we need to do...
simonihmig commentedon Oct 18, 2020
The events in that RFC were a bit tricky as they were non-bubbling events that as such don't play well with EventDispatcher's event delegation approach and as such were harder to support. But
touchstart,touchmoveand whatever other events might be related to this issue don't have this problem. Rather the issue here is that (non-passive) event listeners are attached eagerly, even if those events are not actually used in Ember components.So, @rwjblue what do you think about not deprecating these, but rather attaching event listeners lazily only when those events are actually used, i.e. reviving your previous work in #17911?
I would guess that this could practically solve the problem here, as in ~99% of apps (my own wild guess), the offending events are not used (at least in that old
Ember.Componentevent method way). And if they are used in the app, you can easily rewrite the usage to attach event listeners manually (similar to RFC486's transition path) - which would enable the lazy approach to not attach non-passive event listeners.rwjblue commentedon Oct 19, 2020
Ya, that definitely seems fine to me. Might want to make only these lazy (since I suspect most apps won't use them) be making all of them lazy.
Ultimately, I expect all of the event dispatcher code to be gone when
@ember/componentis no longer used...