Although I cannot find the reference at this time...
The process is a chemical reaction between heavy metals (usually found in the onion or garlic depending on soil conditions) and natural sulphurous compounds that the bulb makes.
As for the heavy metals, the usual suspect are copper, zinc, iron, manganese.
I have observed that Spanish white onions often do that when sweating.
Growers believe that adding copper to the soil makes for better onions as per article alludes:
COPPER REQUIREMENTS FOR ONIONS GROWN ON ORGANIC SOILS IN NEW YORK.
Zinc addition apparently helps according to this article:
Effect of sulpur and zinc application on onion yield and sulpur and zinc uptake in three soil orders
Maybe some farmers are overdoing it with the metallic ions!
Luc H.