int imageCount = min(max(pSurfaceCapabilities.minImageCount(), 2), pSurfaceCapabilities.maxImageCount());
does not handle the fact that maxImageCount() may return 0 to indicate "no limit", setting imageCount to 0 and creating a zero-image swapchain. The application subsequently crashes with "Index 0 out of bounds for length 0".
In createSwapchain(), The line
int imageCount = min(max(pSurfaceCapabilities.minImageCount(), 2), pSurfaceCapabilities.maxImageCount());
does not handle the fact that maxImageCount() may return 0 to indicate "no limit", setting imageCount to 0 and creating a zero-image swapchain. The application subsequently crashes with "Index 0 out of bounds for length 0".