How can `resolution` be a NaN here?

When computing the size passed to `getResolutionForExtent` here you should assert that the size is non-empty (both elements > 0).