ReplayKit: startRecording () the completion handler is never entered

Description of the problem

The startRecording () completion handler is never entered, although the "Allow screen recording in $ AppName" pop-up is displayed. Sometimes "Allow screen display in $ AppName" is displayed. This also happens when I uninstall the application, reboot the device and clean / build the project. I am using iPad Air 2 with iOS 11 and Xcode 9.

Study

This problem seems to have been a problem in earlier versions, see here: replaykit startrecording sometimes never enters the completion handler . I cannot claim that turning off Wi-Fi or a stable internet connection solves this problem and this problem does not resolve in iOS 11.

Here is the code I'm using:

@IBAction func recordButtonTapped(_ sender: UIButton) { if !recorder.isRecording { startRecording(sender) } else { stopRecording(sender) } } private func startRecording(_ sender: UIButton) { guard recorder.isAvailable else { print("Recording is not available at this time.") // Display UI for recording being unavailable return } recorder.startRecording(handler: { (error) in guard error == nil else { print("There was an error starting the recording.") print(error!) return } print("Started Recording Successfully") DispatchQueue.main.async { sender.setTitle("Stop Recording", for: .normal) sender.setTitleColor(.red, for: .normal) } }) } 
+3
source share
1 answer

I think I found the answer myself. Try this and confirm if it works:

  • Delete application
  • Clean Xcode Project
  • Hold the power button of your iOS device.
  • When the slide to turn off appears, hold down the Home button until the screen starts flashing black, then release all the buttons
  • Run the Xcode project again
  • Handlers should now be called again

My suspicion is that there is an error in the shared instance of the recorder that can only be reset when cleaning the device RAM.

Edit: I also noticed that this error only occurs when I stop the application with Xcode during recording. If I put the application in the background or turned off the application using the iOS task manager, this error does not appear when the application starts again.

Conclusion: DO NOT turn off the application using Xcode while recording is in progress. If you use the iOS task manager instead, it will continue to work correctly and deliver callbacks.

Edit 2: An error report has been sent, and Apple replied that they know about this problem, working on it to resolve it.

+2
source

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


All Articles