It's been happening since I started playing on my new PC a while back, I didn't have this problem on my potato Linux laptop. When I'm walking around, running, fighting, building, doesn't matter, the camera will get thrown upward toward the sky every once in a while without me having done it.
It's been happening for quite a few versions now.
Doesn't seem to be tied to frame rate, high or low it happens.
View distance doesn't change anything, near or far.
Playing with or without Optifine doesn't change it.
Single player or multi player it happens.
Changing mice doesn't change it. I have a wireless mouse and a wired trackball, it's happened on both.
May possibly happen when clicking/swinging?
And just in case my hardware or OS may be an issue.
Ryzen 5 2600
MSI B450 Tomahawk
16gb 3200 Mhz Ram
Intel 660p m.2
RX 570 4GB
Old laptop was a Pentium P6000 then an i5 540m with 1.5gb of ram and a SATA SSD. Anything would be immensely helpful because I have no idea what's going on, I've almost tossed myself off a cliff and died to mobs because of this. Not to mention waste glass and glowstone.