MTKTextureLoader very rarely loading magenta textures

I was wondering if anyone had any insight into why MTKTextureLoader might very rarely return a texture which is just fully opaque magenta (each pixel is #ff00ff).

What I know:

  • I'm using MTKTextureLoader.newTexture(URL:options:) to synchronously load the texture within a standard, synchronous dispatch queue (though the single texture loader itself is created on the main thread).
  • No error is thrown in the above call and nothing is printed to the console, and a texture is returned.
  • The URL of the texture resides on the local filesystem and points to a fairly unremarkable 512x512 JPEG.
  • The resulting texture returned by the loader is the correct resolution (but every pixel is magenta).
  • The majority of launches of the app load all the textures without any issues (I think at least 90%), but if a texture does fail to load, many others fail to load as well (especially textures which are loaded immediately after a failed one). The exact same files which load incorrectly in one run of the app will load correctly in another run.

For completeness, the texture loader options:

textureLoaderOptions = [
	.allocateMipmaps: false,
	.generateMipmaps: false,
	
	.textureUsage: NSNumber(value: MTLTextureUsage.shaderRead.rawValue),
	.textureStorageMode: NSNumber(value: MTLStorageMode.`private`.rawValue)
]

Hi Aquiss, would you be able to provide a sample project that reproduces your issue? If so, can you file a Feedback Assistant Report with the following information:

  • The system configuration: Hardware and software versions of the device reproducing the issue .
  • The version of Xcode you are using.
  • A sample project reproducing the issue for you.

We will take a closer look at this on our end. Please share the Feedback Assistant report ID here.

MTKTextureLoader very rarely loading magenta textures
 
 
Q