Posts

Post marked as solved
2 Replies
1.9k Views
I'm using MTKTextureLoader to try and load a texture it works on iPads, but not on iPhone where I get the error : Error Domain=MTKTextureLoaderErrorDomain Code=0 "Image decoding failed" UserInfo={NSLocalizedDescription=Image decoding failed, MTKTextureLoaderErrorKey=Image decoding failedI'd like to know why, how to detect it, and how to work around it.im working with devices using iOS 11 and 12, but the version doesn't seem to make a difference, just iPad/iPhoneSetup to hand right now:iPhone X: iOS 12.1.3 , A11 GPUiPad : iOS 11.4.1, A9 GPUThe texture is JPG format, size 8192 x 8192, and when it loads, it has the pixelformat MTLPixelFormatBGRA8Unorm_sRGBThe code to load it is: NSError *textureError; //self.texture =[textureLoader newTextureWithCGImage:image.CGImage options:textureLoadingOptions error:&textureError]; self.texture = [textureLoader newTextureWithContentsOfURL:textureURL options:textureLoadingOptions error:&textureError]; if (textureError) { NSLog(@"Texture failed to load %@ with error : %@", image, textureError); return NO; }The commented out code was checking loading the texture from an UIImage, the result is the same.Thinking it was the feature set, I checked the devices supported all the iOS 11 feature sets, the iPhone support all of them, the iPad supports all but MTLFeatureSet_iOS_GPUFamily4_v1 . I was expecting the iPhone to not support one.I saw this question which has the same error: https://forums.developer.apple.com/thread/97218I haven't tried the solution yet but it's my next step, but it won't be a very useful solution if I can't detect when I have to use it.
Posted Last updated
.