What are the potential risks of leaving a device in public, but locked?

Let’s say you’re in a public café, or conference, where you trust your device won’t be stolen if you go to the bathroom for 5 minutes, but you don’t trust it might not be tampered with.

What are the potential security risks I might run into here, assuming I lock/log off my laptop’s (windows / mac / linux) user session, maybe even turn it off? Similar question for locked android/mobile devices as well.

It would be nice to include even unlikely but realistic scenarios, such as attacks that might take more than an hour or similar.