The bug
After briefly exiting the swimming pose, a server-client desync can happen whether the player is in the swimming pose. This makes you able to refill your oxygen meter close to, but not above, the water surface.
This can be reproduced by e.g. killing a fish while swimming in full speed.
How to reproduce
Find some water
/summon cod
start swimming
Try to hit the cod without slowing down
If you did not leave the swimming pose briefly, try again
Otherwise swim close to the surface
β β Your air bar refills
Linked issues
is duplicated by
relates to
Attachments
Comments

No bubble columns nearby. Attached video file as well.

Does this happen in every world or just in that spot? If it is the latter, can you post the world file to the ticket? If the file size is too large, you may provide a link to it from another site.

This has happened on two different computers on two different worlds.

I also noticed that if I bob above water and go back down and repeat this a few times, the bar will sporadically fill and deplete even when completely submerged*
I might have reproduced this, but I'm not sure and I'd like your input if that's your issue.
In your video, I noticed you are killing some fish. I think I reproduced this, but only when killing fish. What sometimes seems to happen is that the player very briefly exits the swimming animation (but still stays underwater). After that, it seems like the game is kinda confused whether you are in the swimming animation, so you can refill air as if you were not swimming.
Please confirm that this is required to trigger the bug, or if that happens always, or if there are other ways to reproduce this.

I believe the trigger is what you said, the game gets confused when killing fish or breaching and reentering a water source very quickly.
Updated description accordingly.

Thank you for your help

I also discovered that this happens while cutting Seagrass as well

I don't understand how this is marked as trivial when it breaks an essential feature that was recently added to the game, and could even be used as a cheat.
Still happening in 1.15 (Final). I shall add this happens on a 1.15 server AND in singleplayer. Also, I guess due to a desync when attacking entities underwater (kelp is not affected by it), the game thinks I am 2 blocks tall, thus I get refilled bubbles one block beneath water surface even though I continue swimming. The game does not seem to recognize it fast enough? Or probably anything else. It's weird though.
Wanted to add, that this is still happening in 1.15.1 Pre-release 1.
Obviously, since nothing changed between 1.15.1 pre 1 and the 1.15.1, this bug still exists in 1.15.1 release version. Sorry for spamming each version in here lol
I am not sure if there is any other way to update this report so it gets addressed.
It's perfectly fine like that.
If you want, you can also use the #java-requests channel of the official Mojira Discord server, but it's perfectly fine to post comments here.
Still happening in 1.15.2 Pre-release 1.
Aaand here we go again: Still happening in 1.15.2 Pre-release 2. π
Happening in 1.15.2 andΒ 20w06a.
I am just adding, this bug is even more severe due to rubberbanding when you try to enter a 1x1 hole. You can't enter it due to the desync where the game thinks you are two blocks tall. After exiting the swimming pose and start swimming again it's normal. But this happens a lot if you do something underwater where you continue swimming after briefly exiting it by such as killing fish. So rather make it like killing fish does not make you jump up again for a split second or something else needs to be figured out. This bug has been around since 1.13 and I think it's time to get rid of it by now where underwater activities get more and more important. It's even more stressful when you try to fight the guardian temple underwater. You rubberband everywhere if you fight the guardians and if you swim a little too high. Please update the bug report, this is not only for breathing but also for things like the guardian temple or entering 1x1 horizontal holes, basically everything with a block above you. Otherwise, Bryan, do you think you could give me rights to this thread so I can update the affected versions?
This bug seems to be fixed with 20w22a, maybe affected by this fix: "MC-134755Β - All short mobs drown just below the surface of water" or also because of "Minor optimizations in collision detection"?
I seem to have this issue on 20w21a but it isn't appearing in 20w22a for me now! I can now briefly swim below the surface and do not get any bubbles back and I also do not rubberband in 1x1 holes under water anymore! Does anybody share the same experience?Β

I think you might be right, I marked it as not fixed because I figured Mojang didn't fix it lol.
Also in regards to the previous comment, I didn't make the information for the description.
...does this also mean that MC-129568 was fixed?
Idk.
Btw. you know if you keep updating this... this cannot be resolved anymore tho, because it was fixed by another bug fix and thus they cannot reproduce it anymore so I doubt they can fix it anymore.

I have this issue on a 1.8 to 1.17 server

Can confirm in 1.19.3

Can confirm in 24w40a

Can confirm in 24w46a
Are there any bubble columns nearby? If not, can you please attach a short video of the issue occurring if possible?
This issue has been temporarily closed as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.
Quick Links:
π Issue Guidelines β π¬ Community Support β π§ Customer Support β π Game Wiki