If we enable the "Metal API Validation" in the scheme, then sometimes my code crashed here:
failed assertion For color attachment 0, the render pipeline's pixelFormat (MTLPixelFormatRGBA8Unorm) does not match the framebuffer's pixelFormat (MTLPixelFormatBGRA8Unorm).