replaykit startrecording sometimes never enters completion handler

南笙酒味 提交于 2019-12-06 04:19:53

问题


I am using replay kit to save a video of my screen during gameplay but randomly on occasion startRecordingWithMicrophoneEnabled and recorder.stopRecordingWithHandler never enters the completion handler

it doesn't throw an error, it just runs and hangs indefinitely.

if recorder.available && recorder.microphoneEnabled {
    recorder.startRecordingWithMicrophoneEnabled(true) { [unowned self] (error) in
        if let unwrappedError = error {
            print(unwrappedError.localizedDescription)
        } else {
            print("called")
            self.manager.instructions.text = "Click to Start Game"
        }
    }
}

if recorder.available && recorder.microphoneEnabled {
    print("initiating stop recording")
    recorder.stopRecordingWithHandler { [unowned self] (RPPreviewViewController, error) in
        print("in completion handler")
        if let previewView = RPPreviewViewController {
            print("will transition to gameplay video")
            previewView.previewControllerDelegate = self
            self.presentViewController(previewView, animated: true, completion: nil)
            self.sessionHandler.session.stopRunning()
        }
    }
}

回答1:


I was getting this same thing. Was working on one device, and not on another. Only difference was the working device was on iOS version 10.1.0 and the other was iOS version 10.0.2 - upgraded to 10.2.0 and it started working immediately.




回答2:


I had the same problem and just found its cause (or maybe just a cause). If your device is connected to a WiFi that has no internet access this problem occurs. If you connect it to a WiFi that has internet access or disable WiFi it works just fine. I guess when starting a recording, ReplayKit tries to connect to some Apple servers but never reaches them and also never times out. You can observe the same behavior with the App Store. When you are connected to a WiFi without internet it tries to load the store forever and never times out.



来源:https://stackoverflow.com/questions/40033653/replaykit-startrecording-sometimes-never-enters-completion-handler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!