ARVideoKit
ARVideoKit copied to clipboard
LivePhoto = nil CRASH
![screen shot 2018-07-22 at 10 55 05](https://user-images.githubusercontent.com/19663985/43044485-a47babc8-8d9e-11e8-80a2-f1759a131337.png)
![screen shot 2018-07-22 at 10 55 47](https://user-images.githubusercontent.com/19663985/43044486-a794ffbc-8d9e-11e8-9940-a8fb383accba.png)
I am using iOS12 beta 4 with XCode 10 yes, but the same problem was happening with iOS 11.4
This occurs regularly when actioning a livePhoto:
if arVideoKitRecorder!.status == .readyToRecord {
audioManager.play(.CameraShutter)
livePhotoState = .takingLivePhoto
livePhotoCaptureTimer = Timer.scheduledTimer(timeInterval: livePhotoDuration, target: self, selector: (#selector(finishedTakingLivePhoto)), userInfo: nil, repeats: false)
caprturingQueue.async { [weak self] in
self?.arVideoKitRecorder?.livePhoto(export: true) { [weak self] ready, photo, status, saved in
#if DEBUG
log(self!, message: "LivePhoto process concluded. ready:\(ready) status:\(status.rawValue) saved:\(saved)")
#endif
self?.livePhotoCaptureTimer.invalidate()
self?.livePhotoState = .ready
//if ready {
//Do something with the `photo` (PHLivePhotoPlus)
//}
//if saved { //saved flag is not reliable
self?.overlay?.inform(.livePhotoSaved)
//} else {
//self?.overlay?.inform(.livePhotoFailed)
//}
}
}
}
Settings:
arVideoKitRecorder?.onlyRenderWhileRecording = true
arVideoKitRecorder?.contentMode = .aspectFill
arVideoKitRecorder?.enableAdjustEnvironmentLighting = true
arVideoKitRecorder?.inputViewOrientations = [.landscapeLeft, .landscapeRight, .portrait]
arVideoKitRecorder?.deleteCacheWhenExported = true
@gheatley I can see from your screenshot "Generate+LivePhoto.swift: line 58", the attempt to unwrap photo
has already failed in this case. So I think your issue should be unwrapping a nil value.
Sometimes the LivePhoto works ok, sometimes it doesn't. The problem is originating here in Generate+LivePhoto:
PHLivePhoto.request(withResourceFileURLs: [keyLiveFrames, keyLiveFrame], placeholderImage: UIImage(cgImage: cgImg), targetSize: .zero, contentMode: .aspectFit) { photo, settings in
logAR.remove(from: keyFrame)
logAR.remove(from: liveFrames)
if let livePhoto = photo {
let finalPhoto = PHLivePhotoPlus(photo: livePhoto)
finalPhoto.keyPhotoPath = keyLiveFrame
finalPhoto.pairedVideoPath = keyLiveFrames
finished?(true, finalPhoto, finalPhoto.pairedVideoPath, finalPhoto.keyPhotoPath)
return
}else{
let finalPhoto = PHLivePhotoPlus(photo: photo!) //CRASH photo = nil HERE
finalPhoto.keyPhotoPath = keyLiveFrame
finalPhoto.pairedVideoPath = keyLiveFrames
finished?(false, finalPhoto, finalPhoto.pairedVideoPath, finalPhoto.keyPhotoPath)
return
}
}
This is occurring regularly now. I get two errors when things go wrong: Error: Invalid image metadata Error: Invalid video metadata
iOS12 Swift 4.2 XCode10 on iPhoneX device Really could do with sorting this one