Oxygen level sometimes rises

What this problem is related to? (e.g. Game / Launcher / Website / etc. ):

Describe the problem:
There are several weird things going on.

  1. Although the character is underwater, the oxygen level sometimes regenerates a percent. Which is displayed both on the oxygen bar and the percent value.
  2. When you get out of the underwater, the oxygen starts to regenerate fast, but then it jumps to the 100% values.
  3. If you spam the jump key(which puts you into and out of the underwater state), the bar and the value will also spike.

What was the expected behavior?:

  1. The oxygen level(the bar and the percent) never regenerates underwater, unless there is a side mechanics like a source of oxygen(bubbles).
  2. When you get out of the underwater, the oxygen should not jump to the value of 100. It should instead regenerate to that point with increased rate.
  3. If you spam the jump key(which puts you into and out of the underwater state), the bar and the value will also spike. To prevent that, there should be a delay that delays the oxygen loss after you get underwater. You go underwater, and after you’ve been there for like 1-2 seconds, the oxygen starts to decrease.

List the steps that occurred before the problem appeared:
1.
2.
3.

Can you reproduce the problem?:
Yes.

Operating System, Browser version, Antivirus, or any other related platform information (if relevant):

Screenshots/Videos (if available):