The Cryptomatte node produces a bad output when the viewport is in camera view. That's because compositing is limited to the camera region in that case, but the node assumes the full viewport size. To fix this, only consider the compositing region instead of the full viewport.