TL;DR: Something has changed with ARKit capturedImage
in iOS14, and we couldn't make it fit into our flow.
Built with Xcode 12 GM, tested on iPhone 6S 14.0.
We have implemented a flow where we transform ARFrame
to Data
, which works perfectly for devices that are not upgraded to iOS14 yet.
We are getting the ciImage
like:
extension ARFrame {
var ciImage: CIImage { CIImage(cvPixelBuffer: capturedImage) }
}
which we feed in an ImageConverter
:
public class ImageConverter {
lazy var imageContext = CIContext(mtlDevice: MTLCreateSystemDefaultDevice()!)
lazy var colorSpace = CGColorSpace(name: CGColorSpace.sRGB)
public func jpgData(for image: CIImage) -> Data {
guard let colorSpace = colorSpace else { return Data() }
if let jpegRepresentation = imageContext.jpegRepresentation(of: image,
colorSpace: image.colorSpace ?? colorSpace) {
return jpegRepresentation
} else {
return Data()
}
}
}
So, the problem is, when we call .jpegRepresentation
, it gives a warning:
findWriterForType:128: unsupported file format 'public.heic'
And although the jpegRepresentation
is not nil, it's not working for our server, which expects a jpeg data (which still works for iOS13.7 or below devices).
What we tried so far:
if let heifRepresentation = imageContext.heifRepresentation(of: image,
format: .RGBA8,
colorSpace: image.colorSpace ?? colorSpace) {
return heifRepresentation
}
returns nil, and throws the same error with .jpegRepresentation
. Also tried other formats, to no avail.