5d and 4d SCFTs: canonical singularities, trinions and S-dualities