Where did the pie int he face gag originate?

I tried to find out, but while I found references to pies int he face and how funny they are, and implications that it’s from vaudeville or further back, I don’t have a definitive answer.

So, do any of you have possible answers, or sites I missed, regarding who threw/received the first pie int he face/

I even have these images of some Middle Ages court jester pulling the trick, receiving one for laughs.