Where does air in the pipes go?

Let’s say I step into my bathroom, put a stopper in the bathtub drain, and fill it up. I then remove the stopper. There are a few tiny little bubbles, but other than that, the water drains smoothly, with no air coming out of the drain.

Presumably, other than the water in the U-bend, the wastewater pipes are filled with air most of the way down to the sewer system. So where does all this air get pushed when I drain my bathtub?

If the plumbing was done correctly, it will go out the roof vent. If the vent was not there, the u-bend would empty and sewer gas would come into your house.

See wiki for the full description:

Yeah, the pipes don’t all go down. There are also some that go straight up, and usually poke out your roof a little bit.