microsoft/vscode

Editor: scroll jumps randomly (related to Chrome, Electron, xinput)

mariusa opened this issue Β· 394 comments

  • VSCode Version: starting at 1.13.0, up to current
  • OS Version: Fedora 24-27

Looks like VS Code is listening to mouse scroll events, even while it is not active in the window.
Related:
https://bugs.chromium.org/p/chromium/issues/detail?id=608246
https://bugs.chromium.org/p/chromium/issues/detail?id=807187

Steps to Reproduce
requirements: Browser (Chromium / Firefox / Google Chrome), VSCode Editor (Any file type. Ideally a long file to ensure the scroll is visible.)

VSCode: Leave cursor at top of file.
Browser: Scroll, excessively, (For a few seconds) down the page. Even if it's a blank tab with no content.
VSCode: Scroll, ever so slightly, in any direction.
You'll find the editor will jump suddenly further down the active file.

It seems VSCode is receiving the scroll events, for whatever reason; which are all suddenly evaluated upon any form of scroll input in the editor.

Updates based on comments

GUESS: Appears to be an issue with Electron and some input libraries?
Is not isolated to VScode
Fix: Does not yet exist.

Linux Workarounds (Not to be confused with a fix)

imwheel - not suitable for all users
wayland - not suitable for all users
Note: Ubuntu 19.04 (Desktop) appears to be using Wayland.

I'm not sure we will see further updates in here, which is a bit disappointing from the developers, given the amount of comments from affected people. I would like to have some official guidance, even if it's pointing us to other resources.

OS Ubuntu 16.04
VSCode Version 1.13.1

I'm getting a similar issue when Alt+Tabbing between windows.
E.g., Alt+Tab to Chrome to read docs, etc., Alt+Tab back to VSCode, scroll up or down one click on the mousewheel, but the page scrolls down at least 3-4 pages pretty consistently.

UPDATE: Issue still present with all extensions disabled.

This also happens with the right sidebar (Explorer) sometimes, when Alt+Tabbing between windows.
Version: 1.14.2

I've been experiencing this issue for a rather long time. I've never really put much thought into it, and it's not got worse; but I'm starting to really find this ever more frustrating. The actual impact to my productivity is beyond measure.

I'll find that this happens intermittently, but frequently - in which I'll attempt to scroll in the current file, and suddenly I'm scrolled to a location way out of bounds to the input. (Eg; I'm attempting to scroll a few lines, and suddenly I'm at the end of the file).

Some key thoughts may be;

  • Primarily using a touch pad - but I'm very confident this has happened from mouse scroll input also.
  • It's not related to the touch pad input bug - there's no delay - this is INSTANTLY scrolling to a, what I thought was random, section of the file (But as per reporter; may be the end of the file).
  • The scroll is not associated to cursor location (It's not just scrolling to where my current cursor is - more often than not, the cursor is where I'm scrolling from)
  • The scroll distance, as mentioned above, is way out of bounds of input - so cannot be a faulty device (Eg; the touch pad or mouse is actually attempting to scroll that distance)
  • As per @MattMcMurray I spend A LOT of time tabbing between files, CTRL + P quick switching between files, alt tabbing between windows, and workspace swapping.
  • As per @mariusa - I'm using Linux (Debian). I do not use macOS or Windows (So cannot provide tests for these environments).

I've deliberately left the version of Debian (Buster), and VSCode out of this note. I'm using latest of both, however this has most certainly been present for a long time.

I'll endeavor to provide further constructive input in attempts to discover where the problem lies, and attempt to pay more attention when it happens. @ramya-rao-a & @rebornix - I would expect this impacts a lot more users than reported here, hence tagging you here. Just a matter of how long before they too come to this level of frustration.

Edited; included additional information, tagged some people, and fixed some content.

Same here, just couldn't find a way to reproduce it reliably. It is painful indeed.
I don't use multiple workspaces, just alt tabbing between windows (also CTRL + P quick switching between files, but that doesn't seem to affect this). I use just mouse scroll, no touchpad.

tmtke commented

This is bugging me for quite some time, and I think I can reproduce it. It only happens (to me at least) if there is the mini search box at the top right corner of the editor. If I dismiss it, the scrolling disappears.

EDIT: I'm on Windows & OSX.

@tmtke So you have definitely had this happen on Windows?

tmtke commented

@dmblack Yes, it happened on Windows.

tmtke commented

...damn, I think it's not that consistent. maybe a combination of the search box and the inline reference lines. I don't know nothing now :/

nise commented

I can confirm this behavior for Ubuntu 16.04, VC 1.18.1 if I switch between Chromium or Firefox back to VS Code. If switch back from Nautilus or Thunderbird for examples, everything works fine.

I also experience this on Fedora 27
vscode Version 1.18.1

I can finally, and consistently, reproduce. I can also confirm this not only impacts browsers like Chromium, Firefox, and Google Chrome, but other open applications. I can even have no applications open, only my Desktop visible, and reproduce.

For this example, simplified to ensure reliability; requirements: Browser (Chromium / Firefox / Google Chrome), VSCode Editor (Any file type. Ideally a long file to ensure the scroll is visible.)

  1. VSCode: Leave cursor at top of file.
  2. Browser: Scroll, excessively, (For a few seconds) down the page. Even if it's a blank tab with no content.
  3. VSCode: Scroll, ever so slightly, in any direction.

You'll find the editor will jump suddenly further down the active file.

It seems VSCode is receiving the scroll events, for whatever reason; which are all suddenly evaluated upon any form of scroll input in the editor.

@tmtke @mariusa Tagging you two, if you are able to please attempt to reproduce.

Something tells me this is actually an Electron bug. Unfortunately; I don't have any other Electron apps to test with.

Edit: I now have a Windows 10 box at home. Will endeavor to test and add results tonight.

I was also able to reproduce this issue with Ubuntu 16.04. It doesn't matter what app I switch to (tested with Chromium, gedit) although I wasn't able to reproduce by scrolling on an empty desktop. I am not experiencing this with Windows 7. I do not believe that it has anything to do with find or extensions, because when I boot code with --disable-extensions and don't use the find feature, the issue still occurs consistently.

Edit: I don't mean to imply that something is related without better testing, but the Electron/Atom team has a very similar issue that was reported to Atom: atom/atom#15482 The description is nearly identical. There are some suggestions there about switching to Wayland, using editor in a different workspace, etc. I was able to confirm that putting VSCode in another workspace stopped the issue from happening. This looks like at least in my case it's not a VSCode-specific issue at the moment.

As @dmblack surmises, it appears that this is an Electron bug. A related Atom issue has provided steps to reproduce the issue. It seems that Electron is receiving scroll events of Chromium applications that are on top of the Electron application and then replaying them after a scroll event on the Electron application.

Updating Electron seems to fix the issue though, so it's up to the vscode team to fix.

@rebornix May we have your input (Tagging as it's assigned to yourself). Looks like this may be out of our hands otherwise.

  • Is there anything you would like us to try to confirm Electron?
  • Are there any plans for an Electron update with VSCode?

Thanks all others involved so far!

I'm having this issue. It's painful. VSCode is listening to mouse scroll event even while it is not active in the window.

I came to learn that this is a bug from Chromium project and so affecting VScode for being based on electron which use Chrome engine under the hood.

I just filed a bug: https://bugs.chromium.org/p/chromium/issues/detail?id=807187

Not sure if they are taking this seriously.

I wonder if this really is an Electron bug. The Atom editor does not have this issue, and the current Atom version (1.23.3 ) is using a much older version of Electron:

ares: "1.10.1-DEV"
atom-shell: "1.6.15"
chrome: "56.0.2924.87"
electron: "1.6.15"
http_parser: "2.7.0"
modules: "53"
node: "7.4.0"
openssl: "1.0.2j"
uv: "1.10.1"
v8 : "5.6.326.50"
zlib: "1.2.8"

vs code 1.19.3 :

ares: "1.10.1-DEV"
atom-shell: "1.7.9"
chrome: "58.0.3029.110"
electron: "1.7.9"
http_parser: "2.7.0"
microsoft-build: "1.7.9"
modules: "54"
node: "7.9.0"
openssl: "1.0.2k"
uv: "1.11.0"
v8: "5.8.283.38"
zlib: "1.2.11"

If this is an issue in Electron, I suspect much more users would be impacted.
Is there a common extension or tool that triggers this behavior ?
It still happens to me when running vs code with: code --disable-extensions but not when running vscode and chrome on a clean install, without any extensions installed.

I also use PlatformIO and wakatime as extenions, perhaps I should try to install my extensions one by one and see when the issue starts popping up.

Anyway, this is becoming such a productivity drag that I don't see another option short of switching editors. If anyone has found a workaround, please share.

update:

  • also happens on clean install, no extensions installed
  • a rather awkward mitigation strategy is scroll up before scrolling down in vscode. This prevents the sudden scroll to bottom of document as it seems to clear the downward scroll buffer.

The issue is somehow related to libinput. As a workaround, you can replace the libinput with evdev, in ubuntu with xorg it's:
"sudo apt remove xserver-xorg-input-libinput && sudo apt install xserver-xorg-input-evdev". But probably you will need to manually configure the mouse.

@arenddeboer
There's a link earlier in this thread in which Atom demonstrates same, or similar, symptoms - posted by @vacantgeologist and @tranhl

Regarding your 'scroll up' first notes; In my experience; the editor will scroll up or down, entirely depending on your behavior in other applications. As per my testing; I found that this was happening in any application, or even just my desktop - not just other 'Electron' applications.

Regarding a workaround; there are some notes, kindly clarified by @Fullpan. I have not tested them, however; I'd be interested in your experience/result if you give this a go. Please pay close attention to their note regarding potential manual configuration of your mouse.

@mariusa
Could you please update the description / original information to include some additional information found by other users here. This will avoid other posts by users that may miss or misunderstand other content of this now much longer thread.

I'd encourage information or status updates by some of the appropriate developer stakeholders, but we do not seem to have much traction from them.

@dmblack done
@ramya-rao-a Would you please assign to a more responsive developer?

@dmblack thanks for the feedback.
@Fullpan thank you for the libinput / xorg reference.
It made me realize I had WaylandEnable=false set in /etc/gdm/custom.conf. Switching back to Wayland solved the issue for me.

The same here in manjaro gnome when I scroll in chrome and then I press alt+tab to vs code, the scroll put me the end.
DISTRIB_RELEASE=17.1.2
kernel version 4.9.77-1-MANJARO
version vs code 1.19.3
version libinput 1.9.4-1

bitc commented

This happens consistently when using synergy. It's very annoying. Relevant issue: symless/synergy-core#6038

If you're using Ubuntu 17.10 with latest GNOME desktop environment you'll notice this bug too. I tried to install old Ubuntu DE "Unity" and use VSCode on it and I didn't noticed this bug. Everything worked as expected without any errors.

Linux 4.13, X11 with GNOME (not Wayland session)

Another victim of that bug here too, however I have been using zen mode and I'm getting a lower chance of that happening to me, also restarting chrome and VsCode seems in my case to help to "disconnect" the apps scroll events.

System is manjaro KDE plasma 5

This keeps happening to me too. Ubuntu Gnome 16.04. When I scroll in any application and then switch to either vscode or chrome it scrolls relative to whatever I scrolled in the other application. This is obviously very distracting. Anyone having any luck with the workarounds?

Super annoying problem. I'm now getting this problem in Antergos with GNOME.

I've had to put my main opened apps into their own separate workspaces and have a keyboard binding to flip between those.

Does anyone gets this error on zen mode? I'm been using it all the time and I had been 4 days without the issue, I don't know if this may be relevant but guess it couldn't hurt to look into it.

FWIW, I can reproduce this issue in Chrome, VSCode and Atom (using Fedora). But only under X11.

I've experienced this for a while too. If I'm in another application for a while then switch back to vscode, the slightest tough on the touchpad or mouse wheel causes the editor to jump to a new position. I'm on Debian 9.

I can confirm this issue happening on Ubuntu 17.10 on kernel version 4.15.8-041508-generic as well.

I can confirm that this is still occurring for me on Ubuntu 18.04 LTS, VS Code Insiders:

Version 1.24.0-insider
Commit 2404210

(X11)

Damn, it's very annoying bug, switching to browser, scroll something there, then back in VS, one scroll and voila! I'm at the bottom of my file.
Ubuntu 17.10

this annoying issue is occurring on ubuntu 18.04 LTS, and when i switch to wayland or use alt+f2 and r to reload gnome, it seems working good again. Maybe it's a workaround for you.

This needs to be fixed. It's annoying as hell.

@sevenryze It definitely does not apply to Wayland. I'd totally jump ship to Wayland but I get poor performance, odd multi-monitor behaviour and non-existent NVIDIA driver support (for now!).

However, restarting GNOME most definitely does not have an effect.

I wonder; for anyone that is using VSCode (or Atom, or any Chromium/Electron based application) and not suffering from this bug; what desktop environment are you using?

As an aside, I believe using evdev instead of libinput (on X11) also avoids this issue.

I am using Ubuntu 16.04 with Gnome. None other electron app has this issue.

Confirming on Debian 9 / Mate.

dr0p commented

Lubuntu 18.04 user here - I also have some weird scroll behaviour on chrome based apps - slack, vscode, chrome itself. I do not get random scrolls, but rather those apps skip some scroll events. The funny thing here is that LXTerminal is also skipping scroll events. Firefox for example is working totally fine.. it is really annoying. Btw this mix of apps point to direction of the underlying infrastructure - on lubuntu 16.04 i did not had any issues, but after upgrade to 18.04 all hell broke loose..

Same here on Xubuntu 18.04.
But!
Can reproduce only if I switch between VS Code and another window with alt+tab combination, if I switch via click on window on taskbar scroll doesn't jump.

nise commented

40 comments since June 2017 and still no solution? As a consequence I need to change my IDE.

@rebornix I'm not having the issue anymore since using zen mode, but is there a possibility to add this as a milestone or higher priority for next releases?

VSCode it's all great but this bug it's just too darn annoying, I understand there are a lot of issues and road maps are settled to take on improvements and bugs the best you guys can, and I'm petty happy overall on how you guys iterate on the editor, however I really think that this issue is not being given the needed importance as its a visual glitch that happens to break and seriously disturb the developers workflow.

This makes VSCode basically unusable because you cannot switch windows via alt+tab and that's a basic root functionality of the app.

@Esteban-Rocha I can reproduce bug in Zen Mode.

Please stop spamming this bug. VSCode is open source, if you want it fixed, fix it!
There is no value in adding comments demanding a fix from someone else.

@smehrbrodt We are creating awareness.

@smehrbrodt It's not spamming dude, you should first understand how OSS works and specifically how VS Code team works.

@fotonmoton Ohh that sucks :( ! I may be lucky then, if that's the case this means the issue it's even worst as there is no hack around it

As an aside, I can confirm that Atom has resolved this issue for my setup since updating to Electron 2.0.0 (atom/atom#17273). So, noting the work in #45542 I thought this may have also resolved this issue.

However I've tested for this bug on the exploratory builds from that issue and unfortunately it still appears to suffer from it.

edit:
Scratch that, I was not testing Atom layered underneath another window; I was able to replicate it in Electron 2.0.0 powered Atom.

My observation. The issue still exists with the google chrome so, it's hopeless to see it being fixed anytime soon in VS code.

dr0p commented

Okay.. from what I found out so far it looks like it has something to do with input coming from different virtual input devices. Installing and running imwheel without any additional configuration fixes the issue for all affected applications.

@dr0p

It's probably important to mark this as a workaround, and not a fix.

Appreciate your feedback. I'll be looking at implementing a functional workaround until this is addressed by the appropriate resources.

This happens to me when I'm on Ubuntu 18 LTS. Really annoying and effects my productivity.

UPDATE: 😠

Came here after noticing the same, standard Ubuntu 18.04 installation (fresh), VSCode installed from the Ubuntu Software "store". I have the same behaviour if I scroll up and down in VSCode and then switch to Chrome (e.g. this long page) and scroll I get a jump. I also have the same issue with the Slack app which is built on top of Electron I believe, but only when using Alt-Tab - clicking on the dock or the application (if visible) seems to not cause this behaviour.

VSCode version info:

Version 1.24.1
Commit 24f6262
Date 2018-06-13T17:47:35.732Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

Can confirm that installing and running imwheel is a workaround, just have to remember to start imwheel after installing it. Sadly though I notice that running imwheel in its default configuration seems to stop Ctrl-Mousewheel from working as zoom control.

To all the linux falks here, there is very easy hack. you can install imwheel and it will fix this issue. I have been using this hack for a while now and haven't noticed any issues. if you are on ubuntu its as easy as sudo apt install imwheel and then add that into your system startup programs by opening startup applications gui and adding program /usr/bin/imwheel.

Hi there...
I'm using Debian 9 with Mate desktop. From https://forums.linuxmint.com/viewtopic.php?t=241431, as a workaround, disable smooth scrolling from Chrome. Works for me...

c00 commented

I've been having the same issue since Ubuntu 16.04 LTS with unity, had it on Ubuntu 17.10 with gnome and now on 18.04 LTS with gnome. It's happening also with Sublime Text 3, and some other programs. I am using mostly the trackpad 2 finger scrolling, tho I am fairly certain it happens with a mouse as well.

I just installed and run imwheel as per @hardikdangar suggestion, and first results are positive.

It does suggest that the behavior is not related to vscode directly, but rather something to do with the way the X stuff interprets the mouse or something.

FYI guys, there's a 'Subscribe' button. It doesn't serve much of a purpose to say 'Happening to me too' in comment unless you have more input to add to the problem. Please don't take offense to this. I just know it bothers folks who actually write code for open source projects when they get spammed for no reason.

I am using Mate on Antergos distro and am observing this problem. I am always running chrome and vscode on seperate workspaces.The imwheel doesnt work nice for touchpads with precision scrolling, so that is not an acceptable workaround for me.
I have worked around my problem by using xdotool for workspace switching, by overriding default shortcuts.

I do it this way:
Move to workspace to the left:
xdotool set_desktop --relative -- -1

Move to workspace to the right:
xdotool set_desktop --relative -- 1

Hope it helps until this issue is resolved...

imwheel cause a horrible scroll behavior.

I know this is a frustrating bug for many users to deal with (myself included), but let's try not to take that out on the vscode devs. From my understanding this is a bug in chromium, and therefore is making itself known in Electron as well. The vscode devs do amazing work but it could be argued this is out of the scope of their responsibilities. If we want a fix faster the linux community needs to get involved, as the chromium team is actively asking for our help here. Not trying to offend I just really appreciate the vscode teams hard work

paniq commented

same problem here. vscode interacts badly with chrome.

In my case my cursor always jumps towards the top of the page. It's very annoying because it distracts you from reading and can leads to losing focus. Is it related to the same issue?
Ubuntu 18.04, Chrome Version 70.0.3538.67 (Official Build) (64-bit)

graph commented

Oh no I managed to trigger it with electron 3 on ubuntu 18.04.1. I don't know how but it definitely happens less often in exploration.

Version: 1.29.0-exploration
Commit: 8fc99c6
Date: 2018-10-30T11:31:30.266Z
Electron: 3.0.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
Architecture: x64

I've done a tiny bit of testing with different desktop environments, and I found that this bug occurs while using Gnome and XFCE4, but not in LXQT or KDE Plasma. Not sure if this is an isolated case, but at least for now, to me, it seems like GTK-based desktop environments are suffering from this bug, while QT-based desktop environments don't.

Can people having this issue vote on the chromium bug? This one is still open: https://bugs.chromium.org/p/chromium/issues/detail?id=807187

I've done a tiny bit of testing with different desktop environments, and I found that this bug occurs while using Gnome and XFCE4, but not in LXQT or KDE Plasma. Not sure if this is an isolated case, but at least for now, to me, it seems like GTK-based desktop environments are suffering from this bug, while QT-based desktop environments don't.

Thanks for mentioning this. Today I have installed KDE plasma and this bug no longer exists in my new environment.

Scrolling, in general, is a lot smoother as well in KDE.

in ubuntu 18.04 and latest vscode, after alt+tab to opera, alt+tab to vscode editor scrolls down to bottom or top document.

update: imwheel cause a horrible scroll behavior.

Hello Guys, Does anyone knows how to fix this issue? or any workaround until VS Code fixes it?

I switched to firefox, with IE going chromium it’s the best thing for the web as well. 😊

Other than that though, no real workaround so far, and I tried a lot of things. The β€˜imwheel’ tool mentioned above works, but it causes more problems than it solves.

@Epskampie Should be noted here of course, that swapping to Firefox doesn't help! The window you scroll on before swapping back to VS Code (or Atom etc.) does not need to be Chromium based.

I can reliably replicate this with Firefox + VS Code (my daily driver browser) just as well as with Chrome + VS Code.

I can even, in fact, replicate this with Firefox + Chrome, by:

  1. Opening both Chrome and Firefox on a page that can scroll.
  2. Going to Firefox, and scrolling down a lot.
  3. Alt-Tabbing to Chrome and scrolling down a little -- the page will zoom down as per this issue.

You will not observe the opposite, though; Firefox doesn't suffer from the issue itself, just Chromium (Chrome, Atom, VS Code).

Of course this isn't that big of an issue for two browsers. It is definitely an issue for a code editor like VS Code or Atom, where you will commonly be swapping to a web browser (Firefox, or Chrome) and perform plenty of scrolling. Eventually you will swap back to your editor, scroll even a single line and skip to the end of your file!

Definitely hurts the experience.

Antergos with gnome happens too. Code to chrome and vice-versa, happens. Chrome to sublime, dont.

[UPDATE] imwheel fix it.

route commented

OMG I thought there's something wrong with my mouse but I can reproduce what is posted here #28795 (comment)

@yuritoledo could you describe how imwheel fix it plz? what parameters or so. thnx

@aleksanderd you should install imwheel and put it to start with your system. Simple like that :D

If you have a mouse with more buttons than the traditional, you can use imwheel -b 45

I get the same scrolling issue with vscode and chrome on xubuntu 18.04.
I've just tried the imwheel workaround, as suggested above, and the scrolling is no longer influenced by other applications. However now when I scroll very slowly in VSCode the scrolling is not smooth at all, it moves in small steps.

I am using Mate on Antergos distro and am observing this problem. I am always running chrome and vscode on seperate workspaces.The imwheel doesnt work nice for touchpads with precision scrolling, so that is not an acceptable workaround for me.
I have worked around my problem by using xdotool for workspace switching, by overriding default shortcuts.

I do it this way:
Move to workspace to the left:
xdotool set_desktop --relative -- -1

Move to workspace to the right:
xdotool set_desktop --relative -- 1

Hope it helps until this issue is resolved...

for precision touchpads try this after installing imwheel

create config file for imwheel
gedit ~/.imwheelrc
then paste:
None, Up, Button4, -1
None, Down, Button5, -1
Control_L, Up, Control_L|Button4
Control_L, Down, Control_L|Button5
Shift_L, Up, Shift_L|Button4
Shift_L, Down, Shift_L|Button5

now, if you use a precision touchpad, keep the two -1 values.
if you are using a mouse, change them both to 1.

seems to be a workaround for one of the the options - mouse or touchpad.

@geoffroy-noel-ddh

Try to add this guy in your vscode settings: "editor.smoothScrolling": true,

@yuritoledo Actually it didn't work.

@pwaterz about what problem?

Same issue. If chrome is active, then alt tab to vscode then scroll, it jumps to the bottom or top. It's a pretty annoying bug. From what I gathered the issue is in libinput that gnome requires or possibly in the version of electron the vs code uses. I read that atom ide fixed the same issue by updating electron.

route commented

@pwaterz I'm on atom and it doesn't work

@pwaterz you should install imwheel and put it to start with your system. Simple like that

To all the linux falks here, there is very easy hack. you can install imwheel and it will fix this issue. I have been using this hack for a while now and haven't noticed any issues. if you are on ubuntu its as easy as sudo apt install imwheel and then add that into your system startup programs by opening startup applications gui and adding program /usr/bin/imwheel.

THANK YOU hardidangar and dr0p. Linux Newbie, here. Hope to pay back the community in the future.

The issue that I have found with the imwheel workaround is that it alters the scroll behaviour and adds a small but noticeable delay when scrolling (especially noticeable if you don't use smooth scrolling everywhere).

I also want to point out the imwheel isn't a perfect solution. I've noticed some odd behavior since switching to it. I think the issue with imwheel are less of annoyance than the scroll jumping issue prior but I would not consider it a fix, it's more a band-aide.

Have that problem on Arch Linux with Gnome using Chrome and VSCode. After switching from Xorg to Wayland, this does not appear anymore. I was using Xorg for compatibility reasons.

Since for me imwheel causes other problems, tried alternatives and workaround I found is: Don't use alt+tab, instead for example use win+1, win+2. These shortcuts will actually change back and forth to first and second applications in your dock, similar experience without scroll issues.
I guess some of you might not like this since alt+tab is unchangeable, but I can't handle this scroll issue.

Same problem occur on:

Ubuntu 18.04.2 LTS
Xfce 4.12 Desktop or Gnome 3.28.2 Desktop

Occur when I scroll Thunar 1.6.15 or Chrome 70.0.3538.77 (Official Build) and alt-tab to Visual Studio Code my code jump the scroll when I start to scroll the code opened.

As if the jump occurred the same size as I did in the other software.

kuceb commented

This issue plagues me on Gnome 3.2. However, I can do xdotool windowactivate <window-id> and not experience the scroll jump.

If someone has experience writing gnome plugins, you might be able to override alt-tab and instead of doing the normal focus behavior, send the window id to xdotool windowactivate <window-id> or some other command

I was attempting to make alt-tab trigger an additional, hidden scroll down and up using xdotool but unfortunately that didn't seem to work for me. Something along those lines might just be the hack we need.

What do you mean this has been fixed? Can you point to a commit or another thread?

@pwaterz I think @mayaru is referring to this issue in mutter: https://gitlab.gnome.org/GNOME/mutter/issues/401

One of the more salient comments on that issue:

It doesn't happen in Wayland, just in Xorg but again, only in Mutter based WMs.

If it just happens on Xorg, IMHO it's a strong indication it's not really mutter's fault (if anything, it's doing the focus change in a way the application didn't cater of, but there's nothing to "fix" about it)
With Xorg smooth scrolling, scroll axes are transmitted as 2 dx/dy axes, which accumulate the scroll performed thus far. The catch is that this state is global to the whole session, if you scroll on an app, go somewhere else and scroll, and go back to the app, it will see values affected by the scrolling outside.
Toolkits (I'll include electron here) must be smart about this, and reset their own state when the pointer enters the application so that the changes in dx/dy that happened since the last time are ignored.
This is a known issue with XI2.3 smooth scrolling.

That analysis sounds about right, as this problem plagues both code and chrome. Details were added to this issue (first opened in May 2016!): https://bugs.chromium.org/p/chromium/issues/detail?id=608246

IMO, the appropriate thing to do now is put pressure on the chromium team to fix their bug.

It is not just from Chromium, I reproduced it on my file manager (Ubuntu 18.04) and even on a blank desktop, just scroll on any page and return to vscode and scroll again, all the previous scroll events fire.

There are two things to note tho-

  1. The amount of scroll in vscode is exactly equal to the number of scroll events you fired in the other window.
  2. The scroll burst gets cancelled if you change the device i.e using mouse wheel to scroll other windows and use touch pad for the first scroll in vs code will cancel it.

I also noted that this isn't just with vs code, you can scroll on vs code and return to Chrome the same burst will happen. Notably, this won't happen if you switch between different windows of the same application.

It is not just from Chromium, I reproduced it on my file manager [...]

Right, it's Chrome-based apps not handling those scroll offsets correctly -- it doesn't matter which app you scroll in before alt-tabbing over to code/chrome/etc. Chrome needs to reset its internal scroll state in this scenario (edit: and by "Chrome", I mean the shared code base used by Electron apps / Chrome / Opera(?) / etc -- I didn't mean just the Chrome/Chromium app).

This issue plagues me on Gnome 3.2. However, I can do xdotool windowactivate <window-id> and not experience the scroll jump.

If someone has experience writing gnome plugins, you might be able to override alt-tab and instead of doing the normal focus behavior, send the window id to xdotool windowactivate <window-id> or some other command

If this is true then it should be possible to write a gnome shell extension to hack the built-in alt-tab switcher:

https://gitlab.gnome.org/GNOME/gnome-shell/blob/master/js/ui/altTab.js

and replace it with xdotool. I've been trying to do that with no success, for I have very little experience in gnome extension developing... If someone succeeded please share it! The scroll jumps are really driving me crazy now.

mayaru in 1.32.2 problem not fixed...

imwheel not help...