[1] This texture is common in aphanitic, or glassy, igneous rocks that have come to the surface of the Earth, a process known as extrusion.
When this happens gasses dissolved in the magma are able to come out of solution, forming gas bubbles (the cavities) inside it.
When the magma finally reaches the surface as lava and cools, the rock solidifies around the gas bubbles and traps them inside, preserving them as holes filled with gas called vesicles.
[2] A related texture is amygdaloidal in which the volcanic rock, usually basalt or andesite, has cavities, or vesicles, that are filled with secondary minerals, such as zeolites, calcite, quartz, or chalcedony.
Rock types that display a vesicular texture include pumice and scoria.