[Read more about the rise of homelessness in California, and the backlash.]

Taken together, the investments by Facebook and other companies show the degree to which large employers in the Bay Area and other tech centers are having to aid in the basic governance of their regions if they plan to keep expanding — which they absolutely do. Facebook and Google have continued to add employees and office space at a rapid clip, expanding north from Silicon Valley to become some of the largest tenants in San Francisco.

Growing in the Bay Area increasingly means not just figuring out where your top-paid employees live and how they get to work, but also helping other employees do the same. Long before they got involved in affordable housing, Google and Facebook hatched plans to build housing around their campuses. Each weekday morning, an estimated 1,600 private buses — bigger than many municipal public transportation systems — fan across the Bay Area to ferry tech workers to their offices.

“Our cities and local leaders are facing dilemmas that are hard to solve,” said Mila Zelkha, founder of Manzanita Works, a nonprofit that has worked to build housing for teachers by bridging the public and private sectors. “Gifts like this from industry can help fund opportunities so that the fabric of our communities is held together.”

Still, while housing advocates generally applaud the efforts by Facebook and other companies, beneath the large numbers and press-release headlines are a whole bunch of details and fuzzy accounting that have yet to be worked out. For starters, these are not donations but investments on which the companies expect to make money, and substantial portions of them come in the form of land instead of cash.

The investments also give the companies an opportunity to deliver positive news as they face increased scrutiny for their power and influence. Mark Zuckerberg, Facebook’s chief executive, is scheduled to testify on Wednesday before federal lawmakers about its plan to create a cryptocurrency called Libra, as well as online privacy and discriminatory advertising on the site. Facebook has been accused of illegally allowing advertisers to target ads on the platform based on characteristics like race, religion and national origin. This year, the company said it would stop allowing advertisers in key categories to show their messages only to people of a certain race, sex or age group.