Ancient Chinese science fiction

When we think of science fiction, what comes to mind is space operas and barely-credible technologies.  It's very much a genre of the modern age.  But could science fiction have existed in other times and places?  When the Chinese invented gunpowder, what kind of future technology might they have imagined?

Fantasy (fiction) has always existed.  Think of the Epic of Gilgamesh - it's one of the oldest examples of literature of any kind, and although people had a different relationship with their myths than we do today, surely nobody took it as literal truth.  Fantasy is born out of an incomplete understanding of the physical world; the stories are narratives to fill in the gaps and possibilities opened up by not-knowing.  Why does the Nile flood every year?  Let's make up some supernatural beings--with personalities like ours--to explain it.

The genre of science fiction, by contrast, dates back only to the late 1800s and the rapid evolution of mechanical design that accompanied the Industrial Revolution.  Jules Verne and H.G. Wells caught the imagination of a lot of people.  It was born when a generation saw so much technological change that they began to expect change, and they began to wonder what changes the future would bring.  They speculated. 

That notion got me to wondering:  could science fiction have evolved alongside other surges of technology?  In the medieval Arab world, when they mastered the distillation of alcohol ("al-kohl"), did they cure some disease and invent some new kind of boat at around the same time, leading people to wonder what was next?  Was there speculative fiction in ancient China when they pioneered papermaking and invented the compass?

The thing is, "fiction" as we understand it today - as leisure reading for entertainment - is a product of the age of the printing press and of disposable income and time.  Gilgamesh, on the other hand, was probably pregnant with symbolism and lessons for members of Mesopotamian society; I imagine it was required reading.  Literacy rates were low and everybody was busy just surviving, so stories had to be important to be passed on.  So with some disappointment I must conclude that it's unlikely that science fiction flourished in the silicon valley of the Orient.  There would have been no audience, and it wouldn't have been thought important enough to write down.  Too bad.