Post not yet marked as solved
Post marked as unsolved with 1 replies, 272 views
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)
]