I'm running macOS Mojave on a Mac Mini. Built-in VNC server works perfectly when you connect for the first time after reboot, however if you disconnect from it for more than five minutes you can't connect again - it displays the username that was used for the last session and a spinning wheel. Connecting via ssh and killing screensharingagentd doesn't help, only a reboot does. I've verified all the power saving settings are off. There are two virtual machines with macOS High Sierra and Sierra running on this same Mac Mini and I can connect to them without any issues.
My workaround for this problem is to login via ssh and kill loginwindow process:
sudo pkill loginwindow
This will allow to login via VNC then.
With the iMac at work, we had to turn OFF the option under
System Preferences - Sharing - Screen Sharing - Computer Settings to allow
VNC viewers may control screen with password. Then VNC Viewer prompts for the username & password of the iMac (assuming
Only these users: is selected for
Allow access for). Multiple connections work fine with that setting disabled. Hope this helps.
Some more detail, as I'm seeing very similar behaviour, possibly the same.
Using RealVNC client connecting to RealVNC server on Mojave, works perfectly every time. Using this method you are connecting via the cloud using RealVNC to negotiate a session.
Using RealVNC client connecting to Macs own "ScreenShare" utility, via bonjour or local IP address, does not use the RealVNC server, and works for the first few attempts, but leave it for 5 minutes without logging in, then try again and it fails exactly as described, Lockscreen with User's name and picture, but a spinning wheel beneath, with no option to login.
Reconnecting via RealVNC server is still possible whilst in this state.
Stopping and starting ScreenSharing only kills the window with the spinning wheel, it has no other effect.
A reboot of the MAC, and it works again....for a while.
Worked fine on High Sierra.
Not a fix, but another work-around to clear the locked spinny screen is to access the mac (physically) and log out the user. My Mini is in a server closet, close to my desk, so this is annoying but not too difficult.
(I am going to try the option above to tinker with the connection/login)
From this article:
Apple have added a new security layer to macOS 10.14 Mojave. After upgrading your Mac to Mojave, VNC Server will allow only view-only remote access until such time as you've granted access to the vncagent application (installed as part of VNC Server).
To do this, open System Preferences > Security & Privacy > Privacy > Accessibility. Click the lock button to make changes, and + to add a new app to the list allowed to control your computer. Navigate to
/Library/vnc/vncagentand select the Open button