In my experience there is a lot of hostility to undocumented immigrants (a.k.a illegal immigrants) but very little to people to immigrate legitimately.
US population: ~60% white non-hispanic, 20% hispanic, 14% black, 6% Asian
Japan: 98.5% ethnic Japanese
Immigrants in the US + their US born children = 27% of the population, roughly 86 million people, or equal to 3/4 the size of Japan's entire population. Such hostility.
The experience of being a westerner in China is much worse than in Japan IME. I can’t speak for India or the continent of Africa, but in the latter case I’d guess that it varies widely by country.
I suspect that’s the key right there. From friends who are the same, I get the impression that in Japan if you’re of Japanese descent the expectations had of you are very different than the typical gaikokujin.
Most of the world is China, India and Africa.
The rest of the developed world is vastly better than Japan when it comes to treating immigrants better.