• Shrinkage porosity characteristics are strongly correlated with the solid microstructure skeleton in Mg−12Al alloy.
• Higher permeability of the solid skeleton leads to a lower number density of shrinkage porosities.
• Cooling rate significantly influences the distribution, morphology, size, and number density of shrinkage porosities.
• Controlling microstructure characteristics can effectively reduce shrinkage porosity formation.