How does a WiFi client choose an AP if two have the same SSID?

Solution 1:

It varies with the client device. Some are better than others (at least at making the sensible choice of AP as seen by humans managing the system) so the methods obviously vary.

In general, a sensible approach evaluates the signal and signal to noise ratio of the available APs and picks the one with the best signal to noise. I believe that most devices do manage this correctly on radio startup.

An approach which more than one manufacturer seems overly prone to (though a certain fruit-themed manufacturer is notorious for) is to cling to the first AP it sees until it just can't get that any more. Owners of these devices should learn to use a brief trip into airplane mode to try and shake this behavior.

UniFi only "moves devices to a better AP" on the Still in Beta Zero Homing feature, which comes with the downside of everything on one channel and no open networks (and IMHO the other downside of needing to use a V3.x.x controller, when 2.4.6 is still the most stable version of the UniFi controller software.) There is a different feature (MinRSSI) that also requires 3.x.x but does not require everything on one channel and can work with open networks which provides soft disconnect notices to try and urge clients to a different AP when their signal to noise as seen by the AP gets too low. The devices most likely to ignore that appear to be the same devices most prone to hanging onto the first AP they see, from reports.

In many cases one part of the best approach to getting better behavior from clients is to turn AP power down, at least where APs are closely spaced. This, evidently, does not come naturally to most people.