The homeless problem is very bad in California and SF in particular, and it is very concentrated in a small area to the east that looks positively dystopian. But that doesn't represent the whole city. If there is a next time you visit, I recommend spending some time in the panhandle, the Haight, the sunset, basically anywhere bordering golden gate park.