Chrome warning about non-passive event listener for wheel event

On chrome, initializing babylon.js with standard camera input controls causes a warning in console about a non-passive event listener related to wheel events. This warning looks like this when using default playground with latest (5.x):

babylon.js:16 [Violation] Added non-passive event listener to a scroll-blocking ‘wheel’ event. Consider marking event handler as ‘passive’ to make the page more responsive. See www .chromestatus.com/feature/5745543795965952

e.attachControl @ babylon.js:16
t.attachControl @ babylon.js:16
t @ babylon.js:16
createScene @ VM451:6
initFunction @ VM451:33

This is on Windows 10 using Chrome 87, though I suspect the same happens on other platforms and for previous versions of chrome perhaps going back a year or more. It occurs with 5.x, 4.2.x, etc. I found one other post referencing the same or similar: Babylon.js - some warning/error?, however, that post went off track with no real answer.

I believe this warning can be ignored with no real consequences, but I am curious if it would be simple matter to resolve it? At first glance would need to change in scene.inputManager.ts

  • elementToAttachTo.addEventListener(this._wheelEventName, <any>this._onPointerMove, false);

to

  • elementToAttachTo.addEventListener(this._wheelEventName, <any>this._onPointerMove, {passive:true});

I’m not set up to easily test this, so wanted to ask here first before attempting. It’s possible that making this listener passive will cause other problems with babylon’s camera input management, or perhaps not be backwards compatible with existing expectations, but it seemed strange to me that Chrome insists on showing this as a warning.

More info:

  • www .chromestatus.com/feature/5745543795965952
  • developer .mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

(As a newer user, I can only put in two hyperlinks…so please excuse the non-links in this post.)

I totally agree! Do you want to submit a PR? that could be a cool improvment

PR submitted:

I ended up setting passive: false, otherwise I wasn’t sure if there might unexpected interactions. So if PR sticks as originally submitted, it’s less an improvement, and more so simply prevents a confusing warning. Can discuss more in the PR if needed.

Just commented in the PR (missed the conversation here). In general - I love the idea of fixing it. Just a bit concerned about cross-browser issues (well, let’s be honest - IE support :wink: ). We still support IE11. Will that code work?