Generation and evolution of cavitation in magma under dynamic unloading