-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Passive Listener Violation In Chrome #15140
Comments
I faced the same issue. How can I solve it? |
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. |
Is it a related question: #12783 ??? |
@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. |
@evanaj @krisselden @stefanpenner @wellington1993 is this still an issue, perhaps we should close; what do you think? |
@pixelhandler this is still an issue with the latest version: |
It seems that ember >= 3.11 now provides a way to add passive event listeners via the |
Confirm, though it doesn't yet avoid adding the non-passive listener to |
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 |
now `[Violation] Added non-passive event listener to a scroll-blocking X event. Consider marking event handler as 'passive' to make the page more responsive.` won't get logged during tests. see emberjs/ember.js#15140
* update to modern ember-qunit setup ran `ember-qunit-codemod convert-module-for-to-setup-test` * only use ember-cli-shims on neccessary ember versions fixes deprecation warning `ember.globals-resolver` https://deprecations.emberjs.com/v3.x#toc_ember-deprecate-globals-resolver * fix passive listener violations in chrome now `[Violation] Added non-passive event listener to a scroll-blocking X event. Consider marking event handler as 'passive' to make the page more responsive.` won't get logged during tests. see emberjs/ember.js#15140
Disable global, non-passive `touchstart` and `touchmove` event listeners see emberjs/ember.js#15140 r? @locks
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... |
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 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 |
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 |
Our event dispatcher always attaches this events, regardless if they are used or not: https://github.com/emberjs/ember.js/blob/master/packages/ember-views/lib/system/event_dispatcher.js#L62-L65
We should most likely lazily install them as they are required.
The text was updated successfully, but these errors were encountered: