On a modern nuclear submarine, they're currently electrolysis of seawater for a baseline of oxygen production. The reason I don't consider it oxygen neutral is that they're not doing electrolysis of water in compartment air.

As to the ranges while submerged...

https://www.wearethemighty.com/popular/life-aboard-wwii-subm...

The serving of food was often times also dictated by restrictions on the submarines movements. Submarines were under strict orders not to surface during the day when they were within 500 miles of a Japanese airfield in order to avoid aerial observation and attack. In the early days of the war in the Pacific this meant just about everywhere as the Japanese were in control of vast swaths of territory and ocean.

This meant that the submarines stayed submerged during the day and only surfaced at night. In order to compensate, many crews flipped their schedules doing their normal daily routines at night. The crews called this “going into reverse.” This allowed the crew to take advantage of the time the sub was on the surface.

This was important because once the submarine dove after running its diesel engines for hours, the boat would quickly heat up. The engine room temperature could soar to over 100 degrees before spreading throughout the sub. Combine that with the 80 men working and breathing and the air inside could quickly become foul.

The men knew the air was getting bad when they had trouble lighting their cigarettes due to the lack of oxygen (oh the irony).

---

That leads me to https://web.archive.org/web/20170121073605/http://www.public...

Much of a submariner's limited physical activity consequently took place after dark. Some crews still adhered to the standard meal schedule for a U.S. warship at sea, but others turned night into day, adapting meal times to their upside-down shipboard routine.13 The crews called this "going into reversa." Breakfast was served at nightfall. Lunch was dished out at midnight. And dinner, the heaviest meal, came at dawn. The "reversa" timetable was particularly suited to the oppressive conditions on the antiquated S-boats, with their lack of air conditioning. Cool night air entering the surfaced submarine not only reinvigorated the sweating, oxygen-deprived crewmen but helped counter the additional heat of a busy galley.

Even on air conditioned fleet subs, some kitchen crews chose to do heavy cooking at night, when the submarine would not be buttoned up and the ventilation system could whisk cooking smoke along with other foul odors right out of the boat.14 Having the boat open to the atmosphere was particularly helpful for dissipating the intense heat of baking. USS Gudgeon (SS 211), which conducted the first submarine war patrol out of Pearl Harbor, continued to serve meals at standard Navy hours throughout the patrol, but her galley crew put off baking until after dark.15 A bold submarine commander might keep his boat on the surface for all or part of the day, but the galley crew could never count on that, and a boat exposed on the surface in daylight was more likely to make a crash dive at any moment, not an ideal situation for anyone trying to do something complicated in the galley.

...

Bad cooks could certainly decimate a potential meal. Battle could do the same. Whenever Bullhead's deck guns fired, Piatt's muffins and cakes invariably collapsed into lifeless deflation.25 A maritime cooking disaster occurred on USS Harder (SS 257) in 1942 when torpedomen flooded the forward tubes with far too much water. Result: an unexpected nosedive of many fathoms. The crew quickly regained control, and the boat leveled off. A safety inspection revealed no injuries or damage — until it got to the galley. There stood Ship's Cook and Acting Commissary Steward Thomason, "ankle-deep in mashed potatoes garnished with a glittering sea of what had been steaks, gravy and fried eggs."26 In all probability, the meal that eventually got served was a mixture of tinned ham, sugar, salt, water, and modified potato starch, with a little dash of sodium nitrate to preserve its rosy color.

---

That article is a good read for some of the stories. It appears that cooking was preferably done on the surface - not for battery reasons but rather air / veneration. Also not the USS Harder was cooking while firing torpedoes - suggesting submersed operation.