SF has an extreme homelessness problem, smells like urine in upscale pedestrian magnet areas (not just back-alleys) and the residential buildings are poorly maintained to the point it being visually distracting because the land underneath them is so much more valuable than the edifices themselves.
NYC is better, but still fairly grungy. Boston is substantially better along these metrics. Montreal and Quebec city, two of the oldest and, by dint of age, pedestrian-friendly cities on the continent, are leagues ahead of SF as well in this respect.
SF is great. Love the vibe. But lets not kid ourselves into thinking it is clean.