I’m curious if this has actually happened to someone to great dramatic effect
Personally, I’ve had episodes where I was tripping and lost access to the knowledge of passcode but luckily my sort of muscle memory saved the day but its not always a sure thing which was scary at the time
It’s largely dependent on the hardware and software.
For example, old ass iPod Touches/iPhones can be brute forced with special hardware. I watched a video on this recently of some guy who found his old iPhone and wanted pictures off of it and the tech had a machine that would take a few days to guess every possible passcode combination. Though he was able to set a certain possible combination which helped decrease the amount of time to a few days.
That type of brute force is not as possible on modern hardware and software because manufacturers and programmers have gotten wise to it and developed better measures to protect against it, such as timeouts for incorrect passcodes. A few decades ago when we didn’t have this, it would still take a machine a few days to crack the code using brute force, but now you’ve added even more time on top of that to further slow the process, in hopes of the machine malfunctioning or just someone not wanting to waste time doing that.