-
Notifications
You must be signed in to change notification settings - Fork 28
Default to passive: true on document level wheel/mousewheel event listeners #64
Comments
/cc @staktrace @smaug---- |
/cc @ChumpChief Since high precision touchpad scrolling on Edge is already not blocked on wheel events. Edge might be implicitly in favor of the intervention. |
Yes, Edge is in favor. I've seen too many analytics libraries throwing benign wheel listeners on the document :) I'd guess most pages with document-level preventDefaults are also non-scrollable, since it's weird for a user to see overflowing content and a scrollbar but not be able to scroll with mousewheel. Maybe some "parallax" sites that eat the wheel to apply their own physics/animation? Even with this intervention these probably function approximately as expected if setting scrollTop in script wins over the scroll animation. That said, I'm now observing that in Chrome the scroll animation wins over setting scrollTop in script. Is that expected? Is there a means for a developer to halt an in-progress scroll animation in Chrome? You might want to consider changing this behavior to match Edge/FF to further reduce the compat risk of the intervention. P.S. Precision Touchpad doesn't fire any wheel events in Edge so it's perhaps not quite fair to compare against. But regardless this intervention seems good. |
I don't have any objections to this intervention either. It should be straightforward to implement in FF as well. |
Since M65 Chrome is handling wheel events asynchronously: https://www.chromestatus.com/feature/5728708706959360 |
Love the scroll latching and async events :) This is a slightly different point though - regardless of whether a developer is setting scrollTop in response to the wheel event or in response to something else, it seems that developer cannot interrupt the animation. In this specific case, the compatibility risk I'm highlighting is for document-level script takeover of scrolling (e.g. maybe Nicescroll would be an example). Since these are not specifying In any case, I'm in favor of the intervention. Just offering a suggestion in case issues are discovered on that type of construction. |
I understand your concern about the fight between script-driven scroll animation and the native scroll animation which is the current behavior of Chrome and Firefox (tried http://jsfiddle.net/gcxof62e/ on 60.2.0esr (64-bit)) |
Hi Since this has been implemented it has broken a number of smooth-scroll plugins / libraries that remove the 'judder' created by a traditional mouse wheel when scrolling on Chrome. How would you set explicitly set Any help would be wonderful. Paul. |
@RByers or Chrome extensions share same zoom level across popup, background, options and all other HTML documents. That means if a chrome extension is not able to prevent users from zooming in and out on certain pages then the zoom level for all pages gets messed up and UI across all documents in a chrome extension is broken, then their users start to complain about broken UI and give 1 star reviews and uninstall the extension or app. Chrome extension developers prevent this issue by calling Because I work at a company that develops nothing but Chrome extensions I can tell you that all of our chrome extensions are broken because of this change, I'm not sure about how many chrome extensions currently shipped on chrome web store are affected by this change. Also note that not only chrome extensions but many of the Google's own products such as Google AdWords, AdSens and other products that make use of Dart programming language and Above issue was opened on 26 May 2016 , but support for passive events is still not there as of 2019 this just shows it can take months, sometimes years to get these breaking changes to work well with the existing apps and extensions. If you care so much about web developers going bankrupt because of slow web sites, then why not care about chrome extension developers going bankrupt because of messed up zoom levels. Why there is no browser level API to change zoom levels so we don't have to use hacks like I have to record tutorials on how to fix messed up zoom levels and show it to users that mail me that their UI is messed up. But instead of fixing real issues we decide to create more non-issues like making events passive by default. Node’s development direction favoured performance over usability and robustness, eventually backend developers got tired because of that and switched to better alternatives such as Golang. I see chrome developers are also following a similar approach that favours raw performance over usability and robustness, and this discussing already shows how wrong that is :) Never favour raw performance over usability and robustness. In my opinion, robustness and usability is far more important than anything else, and because we are a small team we want our apps to be robust and at the end of the day we want to sleep well in the night rather than having to worry about some event handlers failing to do what they should be doing otherwise if this breaking change was not shipped. |
Maybe I don't understand how this repository is supposed to work. Have Chrome/Blink + Firefox implemented this intervention? If so, why is this issue still open? My specific question is whether WebKit should do it now, but my general question is how to know what the state of an intervention issue proposed here is. |
Firefox has not implemented this. It was discussed in https://bugzilla.mozilla.org/show_bug.cgi?id=1526725 back in February. |
...
I am sorry that your extensions are negatively impacted by the intervention. However e.preventDefault() is not broken: Please not that the intervention for touchmove and touchend has been shipped in chrome 56, and implemented by Edge, Firefox, and Safari layer on. This new issue (opened on Dec 2018) is for wheel events. |
/cc @NavidZ for follow up since I am not working on this project any longer. |
Passing Obviously, the event listeners are not broken but their default behaviour is changed causing them to indirectly break. These days most web development is done using transpilers such as Dart, Elm, TypeScript, GWT, GopherJS to name a few. Above transpilers care more about robustness and less about performance, because first they have to be correct before they can optimise, if the transpiled code is not correct then all the optimisations are useless. JS transpilers are written with consideration of certain things to be true such as all event listeners receiving Some languages that transpile to JS are strongly typed and some of them did not have the positional or optional parameter It is not the static sites like CNN that you used in the demo that are affected, it is the SPAs, Chrome apps, Chrome Extensions, Electron apps, JavaScript transpilers that are severely affected, does your team take all the above into consideration when you implement breaking changes like the above? If your team wants to go out off their way to to implement breaking changes that go against the spec and affect everybody on the web then does you team also go out off their way to make sure that the changes are as less painful as possible to implement and to be used by everybody? Does your team inform library maintainers, and developers who work on popular transpilers before implementing a breaking change, for example: by creating issues? Even the people who wrote transpilers did not know about the changes made to event listeners that were shipped in 2017, I had to go and inform them about the changes and why it is important to implement support for passive events across event listeners, this just shows even those who are affected are not informed about the changes. When working with transpilers, stacktraces are sometimes not useful. Transpilers may log countless warnings to the console, so if calling To mark event listeners as passive in a transpiled code first a developer has to wait for months for support for passive events to be implemented. because the developers who worked on transpilers were not informed about the changes. After that old event listeners can be updated. In our use case, our chrome extensions are required to be manually reviewed by chrome team before they can be released to chrome web store. This review process can take up to 7 days. So it takes quite a while for the developers to notice and adapt to the changes because of not being informed. Looking at the previous breaking changes your team has made, your team does not care about robustness, all they care about is raw performance on mobile devices achieved at the expense rest of the web. Refactoring all event listeners across all projects will definitely take some time but does your team give enough time for everybody to catch up and implement the change? In 2017 when you made changes to the touch events, Google's own projects were broken. Also Chrome Canary browser is not available to Linux users which means a huge group of developers do not get the opportunity to test the changes and see them in effect, they do not see how these changes affect all the apps until they are shipped to production versions of Chrome. |
We certainly considered all the URLs that this intervention might have broken. That will include all the sites including the ones with Javascript transpilers. We also worked with popular frameworks to get this handled on their side such as react.
We do our best in terms of consulting all developers and other browser vendors through GitHub issues, blogposts, console warnings, and whatnot. One of the problems with improving web in general is that there will be always a long tail of websites/usecases that might never go away. We just have to make a call and say if a particular legacy feature usage has gone lower than a very very small threshold that will be good enough to change to make the overall performance of the rest of the web better. It is like breaking a very small percentage of the usecases to get a better performance for the rest of the web. I'm still not sure about your particular usecase to dig further and suggest any other actions for you. But just as another workaround (not sure whether it applies to your usecase or not) you could try having your listener not on the document but in a more nested element. That way it is not going to be affected by this intervention until more frameworks add the support for event listener options. |
I recorded a video that shows broken Chrome extensions because of shared zoom level: https://youtu.be/3NdxRv3LGp8?t=86 Above video demonstrates how some popular chrome extensions that have more than 1,700,000+ combined users are affected by the shared zoom level and above intervention. Here is my proposed solution: Above issue can be prevented by using this Dart code : /// returns whether zoom was disabled or not
bool _disableZoom() {
if (_isZoomDisabled) {
return false;
}
// disabling use of control +/- for zooming
html.window.document.onKeyDown.listen((e) {
if (e.ctrlKey || e.metaKey) {
int c;
if (e.which != null) {
c = e.which;
}
if (e.keyCode != null) {
c = e.keyCode;
}
print('c is ${c}');
if (c == 187 || c == 189 || c == 107 || c == 109) {
e.preventDefault();
// ignore: cascade_invocations
e.stopPropagation();
print('propagation stopped');
}
}
});
// disabling use of mousewheel for zooming
html.window.onMouseWheel.listen((e) {
if (e.ctrlKey || e.metaKey) {
e.preventDefault();
// ignore: cascade_invocations
e.stopPropagation();
}
});
_markZoomAsDisabled();
return true;
} but this code is now invalidated by above intervention. Now many chrome extension developers will be forced to release a fix, it is easy for us to release a fix, but it is not easy for others who are not aware of this intervention and shared zoom levels. |
I made a bug report: |
@NavidZ No other concerns! Now we will not get complaints from users about broken zoom levels. I was very happy when the fix was implemented in Chrome :) |
I'm glad to see your issue fixed. Please feel free to file bugs and be vocal when you seen something wrong and we can always look into them and discuss solutions and workarounds. |
This should not be implemented. This breaks GUI fixes (Gecko is blatant GUI breaker and most GUI bugs/regressions are not fixed). This will make gecko even more unbearable to program with and make engines that do not implement this more cooperative for UX. In example I've ensured that in competent browsers that the X and Y axis scrolling while hovering range type input elements adjusts the input's value. However in Blink/Chrome if the parent element has a scrollbar it will scroll losing focus thereby negating the user's intuition to use their scrollwheel. You are literally advocating that that you know better than web authors and I can dig up two decades worth of almost entirely ignored bug reports to show Mozilla is only further alienating the people who actually know WTF we're doing. Stop dictating what you think web authors should be "allowed" to do. Stop blindly copying Google. |
Web authors can still use non-passive listeners and call preventDefault by specifying |
These behaviors aren't backed by any spec, but these issues are linked: WICG/interventions#35 WICG/interventions#64
What is the status of getting this behavior into a spec? In whatwg/dom#365 (comment) it was noted that we have tests for this in WPT, but seemingly no spec, so I've renamed the test in web-platform-tests/wpt#29039. |
These behaviors aren't backed by any spec, but these issues are linked: WICG/interventions#35 WICG/interventions#64
…e, a=testonly Automatic update from web-platform-tests Make 2 passive-by-default tests tentative (#29039) These behaviors aren't backed by any spec, but these issues are linked: WICG/interventions#35 WICG/interventions#64 -- wpt-commits: cc6fee62b855f6f93ac9c56bf763f91607d75146 wpt-pr: 29039
(As noted in #72, we intend to archive this repository and are thus triaging and resolving all open issues) As noted in #35 I think we can continue to track this work under whatwg/dom#365, see whatwg/dom#365 (comment) |
Chromium/Blink would like to propose an intervention where the
passive
option forwheel
/mousewheel
event listeners added to Document level objects would betrue
by default. To opt out developers can explicitly specifypassive: false
when they want to prevent scrolling/zooming.This intervention is the wheel equivalent of touch scroll intervention which is implemented by Chrome (since M56), Safari1, and Firefox2.
Our statistics show that:
passive
option and more than 98.5% of such listeners do not callpreventDefault()
.See more details in Document Level Passive Wheel Event Listener Intervention
1: Tried on Safari 11 (IOS 11.4)
2: Tried on Firefox 61
The text was updated successfully, but these errors were encountered: