An underwater mass spectrometer uses a semi-permeable membrane to extract dissolved gases and volatile organic compounds from the water. These compounds are then ionized and analyzed by the mass spectrometer to determine their composition and abundance.