make canvas sizing detection more robust