Still not sure what causes it, but the potion bug seems to happen easily (tested with cheat runs so I could do it quickly, though the first time I saw it was a cheats disabled Ritualist run). Conveniently, it happened on the first potion use each time.