The problem in SF is they are out of room to expand. Portland artificially did this by imposing growth boundaries. Compounding SF's problem is that fact that there are no major road arteries into the city making access difficult at best. SF deliberately chose to avoid building highways through the city that could connect it to the rest of the bay area easily substituting light and heavy rail (the Muni and BART). But even in SF, public transit is not popular if you have an alternative. So the city struggles against people wanting cars no choo choo trains and buses.
NYC has simply gotten as large as is practical and as urban density increases there the transportation infrastructure is getting overworked. Doesn't help that the MTA (subway etc.) is run by union hacks and retards, not to mention the corrupt.
In the Electronics Age, unlike the Industrial Age, decentralization of business and most activities is far more possible and practical. So, businesses and people are moving from high density urban areas with pollution, high taxes, crime, poverty, and all the other problems to places that are the opposite of that. Sure, for many uber rich the attractiveness of a high density urban area is the access to all sorts of entertainment, restaurants, and the like but they can avoid the down side being uber rich. They have people that shoo the impoverished and homeless away from where they are, have body guards and security that ensure crime doesn't happen to them. High taxes are a nuisance they put up with, but they have sufficient funds it really doesn't matter because they can always go elsewhere when they choose to.
The people who leave are the Middle Class. They too have a choice but don't have the money to make urban living comfortable or attractive. So, they leave for greener pastures.