Replaykit startrecording sometimes never enters the completion handler

I use the replay kit to save video on the screen during the game, but by chance startRecordingWithMicrophoneEnabled and recorder.stopRecordingWithHandler never enters the completion handler

it does not throw an error, it just starts and freezes 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() } } } 
+5
source share
2 answers

I got the same thing. Worked on one device, and not on another. The only difference was that the working device was on iOS version 10.1.0, and another - iOS version 10.0.2 - was updated to 10.2.0, and it immediately started working.

0
source

I had the same problem and I just found the reason (or maybe just the reason). If your device is connected to Wi-Fi, which does not have Internet access, this problem occurs. If you connect it to a Wi-Fi that has Internet access or disable WiFi, it works fine. I think that when starting a recording, ReplayKit tries to connect to some Apple servers, but it never reaches them and also never leaves the game. You can observe the same behavior from the App Store. When you are connected to Wi-Fi without the Internet, it tries to download storage forever and never shuts down.

0
source

Source: https://habr.com/ru/post/1258184/


All Articles