Most of my thoughts on this topic have been covered, but one significant factor or early firearms is being missed.
When gunpowder was first used in combat saltpeter (a main ingredient) was quite expensive and difficult to amass in large quantities. On the other hand, the first time people were exposed to the loud noise and smoke blackpowder creates it was effectively magic. Some of the first cannons were used more for that effect or as flame throwers than damage.
So in a world where even low level mages an cast firebolt or make thunder, there's questions in my mind if people would have pursued the development. Of course that depends on how ubiquitous magic is in your world, but there were centuries of development of gunpowder before we had any hand-held weapon.
When gunpowder was first used in combat saltpeter (a main ingredient) was quite expensive and difficult to amass in large quantities. On the other hand, the first time people were exposed to the loud noise and smoke blackpowder creates it was effectively magic. Some of the first cannons were used more for that effect or as flame throwers than damage.
So in a world where even low level mages an cast firebolt or make thunder, there's questions in my mind if people would have pursued the development. Of course that depends on how ubiquitous magic is in your world, but there were centuries of development of gunpowder before we had any hand-held weapon.