My main concern on limiting gunpowder in any campaign I would run
would be its strategic effect on power. Cannons made it possible to
knock down medieval castles fairly quickly. This meant that larger,
more centralized, more absolute states were possible. After that the
sizes of states, armies and wars tended to grow, so armies would be in
the tens of thousands, and individual characters less significant, and
more run over by the games of kings.
This is not absolute, many people have been able to write
adventure stories where individuals were significant (for instance
THETHREE MUSKETEERS), but I often prefer a smaller scale.

Once cannons come in, middle ages go out. (The Ottoman Turks used
cannons successfuly in the seige of Constantinople, just before it
became Istanbul in 1453). Offensive wars gain a great deal of
offense.

I am less concerned about individual guns. This took centuries of
development to be signficiantly more effective than crossbows, let
alone trained longbowmen (a big gun advantage was that basic training
took so much less time. )

I like the idea of Realm magic causing gunpowder to explode. Simple,
elegent, raises questions:
What about swamp gas? Natural gas in mines? Coal? Other
flammables? The real world bombadier beetle for instance.

Realm magic cast by true mages is derived from clerical magic, from
the power of the blown up gods. What about clerical spells (realm or
otherwise). If everytime a cleric cast Bless or Heal, gunpowder in
the several yards around went Boom, either clerics or gunpowder would
be less widespread. Gunpowder looked suspeiciously hellish in our
worlds, this would be additional evidence ...

If Realm spells would make gunpowder spontaneously explode (notice
there have been a whole lot of "ifs" in the last few paragraphs), what
about godly spells in the millenia preceding?

Need to do more thought experiments.

Lyndon