-2

Running on Apple TV I get the following error from Alamofire when trying to download a webp file:

Request failed due to an underlying Alamofire error: Response Content-Type "image/webp" does not match any acceptable types: image/gif,image/x-xbitmap,image/x-win-bitmap,application/octet-stream,image/jpg,image/ico,image/x-icon,image/x-bmp,image/x-ms-bmp,image/jpeg,image/heif,image/png,image/tiff,image/jp2,image/bmp,image/heic

Running the same under iOS, again with Alamofire, does not produce this result. Why is Alamofire, at least on Apple TV, not recognizing image/webp as a valid content-type?

Alamofire - 5.6.2 (SPM)
AlamofireImage - 4.2.0 (SPM)
tvOS 15.x 

This question was closed for not being relevant to programming. This is a Swift question related to Alamofire supporting the webp format on tvOS. The Apple documentation seems to suggest it is supported and I am sure other developers will come across the same situation using Apple Swift documentation that would lead them to believe webp is supported. This is highly relevant to any tvOS developer working with differing media content. I respectfully request it be reopened to help others in the future.

C6Silver
  • 3,127
  • 2
  • 21
  • 49
  • 1
    https://github.com/Alamofire/AlamofireImage/search?q=webp There is a good comment: on a Test: `images.remove(.webp) // WebP is only supported on macOS 11+ and iOS 14+.`, and it's AlamofireImage that rejects it, not Alamofire. – Larme Sep 02 '22 at 20:38
  • From what I guess: iOS can render WebP since iOS14, but AppleTV can't. And parsing and rendering yourself the image would be quite consuming, and might need support for external framework from Google (and is it even available on AppleTV ?) – Larme Sep 02 '22 at 20:41
  • @Larme - Apple's documentation would seem to suggest that this is supported on tvOS from 14 forward: https://developer.apple.com/documentation/uniformtypeidentifiers/uttype/3551599-webp – C6Silver Sep 02 '22 at 20:43
  • 1
    @C6Silver That just means the system recognizes the file type. Doesn't mean it can actually render the image. Feel free to give it a test but in my testing neither tvOS or watchOS can render WebP images. – Jon Shier Sep 02 '22 at 21:05
  • @JonShier - You are correct. Not sure what the point of tvOS recognizing webp is if it doesn't work. Regardless, I did brute force check this and the UIImage was nil on tvOS while the exact same code and URL on iOS produced the image. So clearly it is not supported. – C6Silver Sep 02 '22 at 21:11

1 Answers1

0

Unfortunately tvOS (and watchOS) do not support rendering WebP images, despite recognizing the file type. I don't know why Apple has arbitrarily limited support like this, but that's why AlamofireImage doesn't support it on tvOS.

Jon Shier
  • 12,200
  • 3
  • 35
  • 37