Naomi Osaka has survived a scare as fellow former champion Iga Swiatek breezed into the US Open's last 32 at Flushing Meadows.