For my table: You can hide when no one is able to see you or you have an ability that says you can hide. Your hiding ends when someone spots you. The moment someone _can_ see you (or can determine your location by other means, such as sound), that is when you make the Stealth vs. Perception check. If you win, you are not spotted at least long enough to gain some advantage.
For instance, if you round a corner into a cluttered and dimly lit alley, you can use your action to hide (assuming no one has line of sight or there is something to hide behind). When the person that was pursuing you rounds the corner and now has line of sight to you he might spot you. Now you make an opposed check (passive if he takes no action to spot you, rolled if he spends an action searching). If you win, you remain hidden.
Or maybe you want to peek out and fire your crossbow at the guard as he moves past you. Again...that is when you make your opposed check. If the guard is actively looking for you he gets to make a roll. If you win, you get advantage on the attack.
Mask of the wild lets you hide while only lightly obscured in foliage.
Again...at my table. The errata doesn't change anything because that is how it has always worked.
ncG1vNJzZmivp6x7prrWqKmlnF6kv6h706GpnpmUqHypu9Zmm6ido2LBqbGMnqmrmaSWerC6jKGgnaGenHqissWemq1lpJ2ybrnArKJmp5ZiwamxjLCgpZxdlq%2BquMitsGanlmLBqbGMsKaonF2auad6k25vbm9kZA%3D%3D