While Screensaver is on, login window keeps appearing. How can I prevent this?

I have the same problem, and it turns out it is being caused by Firefox. This seems unlikely, so I'll lay out the facts below.

At first, I assumed it was mplayer, VLC, or QuickTime player, all of which will disable the screensaver while they are doing their magic. Especially the first, which is installed via Homebrew and isn't properly written for OSX. However, much playing with these indicated they're not the problem.

Later, I guessed it was my attached bluetooth devices. So I've performed two experiments:

  1. I turned on my screensaver then powered off both the keyboard and trackpad, which are the only two input devices attached to bluetooth, yet the problem persists.
  2. I plugged in a USB mouse/keyboard then turned bluetooth off entirely from the OSX menu bar item. The problem persist even with bluetooth turned off entirely.

After some time, I guessed it was a USB device. I have several USB items plugged in, including several hard drives, a vape pen, and Android device. Unplugging these made no difference.

Finally, after the problem had been going on for several days, Firefox needed a security update and a restart. After restarting it, the screensaver/display sleep worked properly.

Now, whenever I have the problem, if I quit Firefox, the problem goes away. If I restart Firefox, sometimes the problem goes away, but sometimes it persists.

I have NO IDEA why Firefox would be triggering this, and if it weren't for the above facts, I wouldn't really believe it myself. If anyone else has this problem and uses Firefox, please try to corroborate?