Decriminalization is the way to go. Most of the cost of drugs comes from their illegality. A person working a low paying job could afford their drug habits, if you legalize it. It would greatly reduce the crime and violence that dug addicts engage in to get cash to pay for their habits or drug dealers do to hold and expand their territories. Plus, the government can tax it.
Lived in SF for a year 20 years ago. I loved it, but the biggest problem there was the homeless, which seems to have gotten worse since I left. Some problems for curing homeless issues there (some may be addressed now or there may be new issues):
1) Things are so expensive you can't afford housing with a lower paying job unless you get into rent control housing and the vacancy rate was so low that this is hard to do. So a lot of the working poor are homeless due to a lack of affordable housing in the area.
2) The weather there is awesome IMO and a lot of the homeless from the rest of the Bay area, like Oakland and San Jose, move to SF. I remember one day I was like something is wrong. Then I realized I was sweating from the heat. One day all summer. Makes it hard to keep enough homeless housing when more homeless people are constantly moving there from other parts of the Bay area due to the milder weather, especially in the summer.
3) SF also has some huge ass parks that they can sleep and stay in. I lived by the beach in the Richmond district. There are some huge parks to the north and south of where I lived, the Presidio, Lincoln, and the Golden Gate Parks. The homeless would sleep there at night and go downtown during the day to beg.
4) SF makes it pretty easy to be homeless. Porta-potties on the corners in areas with a lot of homeless. You want these because you learn pretty quickly never to walk in an area out of line of sight from the street as those places are just urinals/shitters for the homeless. Allowing them to sleep on the sidewalks all over. Parks that they lived in without being hassled. They had homeless housing, but it was never enough. SF tries to help, but the numbers are just overwhelming. So services for them are never enough.
5) Like all homeless they are a lot of addiction and mental health issues. It is hard to treat them all and I doubt the have the money to do it. Throw in many would refuse the help. I used to take the bus in from where I lived, since it was the first stop, and I was too cheap to pay $25 a day to park my car downtown. I always shared it with the Golden Gate park homeless going downtown to beg during the day. I felt like I was in this Dave Chappelle skit sometimes: