This might be a bit broad [but answerable in a broad sense], and I have no documentary evidence to back things up, but my qualification for this is I am a (retired) professional sound engineer, who now works in the movie industry...
Back in the old "Singin' in the Rain" days, the music would be completed first and the actor would lip-sync to a playback on set.
This was very expensive in terms of film footage, but the only way, technically, they could realistically achieve something like lip-sync.
In later days, when they had multi-track audio recording [from the mid 60's roughly], then the options opened slightly... Until the mid 90's, the way to do this was to sing along to a version completed except for the very final vocal for the film recording, & then use an ADR-type technique of re-singing the vocal along to the final edit of the picture [actually projected on a screen in the sound studio] until they looked like they matched.
Audio tape is, of course, re-usable - so this technique was massively cheaper than filming it til it looked right.
The first professional vocal I ever had to do was done this way; I had to lip-sync to an already-completed cartoon 'singer'. That was about 1980/1.
Since the mid 90's, we've had software that can move a vocal to match another sound track - notably something called VocAlign Pro [other software is likely also available, but that's the one I know and have used for over 20 years.]
This gives you the option of re-aligning the audio of a later-recorded vocal track to the original recorded on the sound stage, so you will never see lip-sync issues. This technique is also used for dialog 'looping' (also known as ADR or dubbing).
Once you have that capability, it ceases to matter which you record first, as you can always go back and time-shift it later.
Practically, it can depend on the state of completeness of the actual song arrangements. The last musical I worked on, all that was set in stone was the song format - verse/chorus/verse etc - all the actual arrangements were still in rough outline. The structures themselves were of course recorded on digital sequencers, so the tempo was nailed solid and could be used as an absolute reference for any later overdubs. So the cast sang to piano/drum arrangements, and everything else will be overdubbed and re-recorded after filming is complete.
Regarding the 'add-on question' - it's better if the actor fully vocalises, i.e. sing it up loud rather than mumble along, as the visual facial/body characteristics will far better match the sound of the final performance.