I use hot corners to lock my screen.
Sometimes, my login window appears but the screen behind it does not turn black. My desktop stays visible, but behind the Login window.
Why is this? Is there any way to fix it?
I assume that you've selected "Start Screen Saver" in the hot-corner in question, correct?
If so, what screen saver do you currently have configured?
The reason that I ask is that some screen savers (although none of the ones that come with your Mac) start with the current desktop image and then apply special effects to it over time. So I can imagine if..
...that this combination could produce the kind of symptoms you are describing.
Edit: Interesting. I don't even have "Lock Screen" as one of the choices on my machine:
Edit 2: I had never tried that option until now. I set up my laptop (model identifier
Because this kind of configuration involves invoking the special power-management circuitry in the machine, there are more moving parts that can go wrong in the process. I believe you have little choice other than to report the problem to Apple, and even if there is a real bug, there will be a chance that the bug is in the power-management circuitry itself and the 'fix' might only come when you can buy a new machine. Or not. Maybe you could get lucky and there this could be fixed by a firmware update or a point-release of the OS.
I like this option, now that you have pointed it out to me. I like that it immediately puts the display to sleep, which makes me feel better about how my battery is being used. Alas, if blanking the screen and keeping it from prying eyes is a higher priority, maybe you should use the "Start Screen Saver" option instead, and set the screensaver to something mostly black like the "Computer Name" screensaver.
I wish I could offer more help.