Replay Kit Not Working iPad iOS11 Bug

ReplayKit: startRecording() completion handler is never entered

I guess I found the answer myself. Please try this out and and confirm if it works:

  1. Delete your App
  2. Clean Xcode project
  3. Hold power button of your iOS device
  4. When slide to turn off appears, hold home button until screen flashes black, then release all buttons
  5. Run your Xcode project again
  6. Handlers should now be called again

My suspicion is that there is some bug in the used shared instance of the recorder which can only be reset when cleaning up the device RAM.

Edit:
I also observed that this error only happens when I stop the running app with Xcode while the recording is in progress. If I put the app in the background or shut down the app with the iOS task manager, then this error does not appear when the app is started again.

Conclusion: DO NOT shut down your app using Xcode, while recording is running. If you use the iOS task manager instead then it will continue working properly and deliver the callbacks.

Edit 2:
A bug report is filed and Apple answered that they are aware of this problem, working on it to solve it.

ReplayKit saving video fails first try with mic

Added retry logic to circumvent the issue. Not the greatest solution but it works.

[self.screenRecorder startCaptureWithHandler:^(CMSampleBufferRef  _Nonnull sampleBuffer, RPSampleBufferType bufferType, NSError * _Nullable error) {
if(CMSampleBufferDataIsReady(sampleBuffer) == false || self.assetWriter == nil)
{
return;
}

if (self.assetWriter.status == AVAssetWriterStatusFailed) {
NSLog(@"AVWriter Failed!");
return;
}

if (CMSampleBufferDataIsReady(sampleBuffer)) {
if(self.assetWriter.status == AVAssetWriterStatusWriting) {
if (bufferType == RPSampleBufferTypeVideo) {
if (!self.startedSession) {

dispatch_async(dispatch_get_main_queue(), ^{
_startDate = [NSDate date];
_recordingTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateRecordingTime) userInfo:nil repeats:YES];

// Disable the idle timer while recording
[UIApplication sharedApplication].idleTimerDisabled = YES;
});

CMTime pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
[self.assetWriter startSessionAtSourceTime:pts];
self.startedSession = YES;
NSLog(@"MP4Writer: started session in appendVideoSample");
}

if (CMTimeCompare(kCMTimeInvalid, self.firstVideoFrameTime) == 0) {
self.firstVideoFrameTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
}

if (self.assetWriterVideoInput.readyForMoreMediaData) {
@try {
[self.assetWriterVideoInput appendSampleBuffer:sampleBuffer];
}
@catch(NSException *expection) {
NSLog(@"Missed Video Buffer: %@", self.assetWriter.error);
}
}
}

if (bufferType == RPSampleBufferTypeAudioMic) {
if (CMTimeCompare(kCMTimeInvalid, self.firstVideoFrameTime) == 0 ||
CMTimeCompare(self.firstVideoFrameTime, CMSampleBufferGetPresentationTimeStamp(sampleBuffer)) == 1) {
return;
}

if (!self.startedSession) {
CMTime pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
[self.assetWriter startSessionAtSourceTime:pts];
self.startedSession = YES;
NSLog(@"MP4Writer: started session in appendAudioSample");
}

if (self.assetWriterAudioInput.isReadyForMoreMediaData) {
@try {
[self.assetWriterAudioInput appendSampleBuffer:sampleBuffer];
}
@catch(NSException *expection) {
NSLog(@"Missed Audio Buffer: %@", self.assetWriter.error);
}
}
}
}

}
} completionHandler:^(NSError * _Nullable error) {
if (!error) {
NSLog(@"Recording started successfully.");
}
}];

App not showing up as a broadcast service in RPBroadcastActivityViewController

Had to add the Broadcast Extension, in Xcode, File -> New -> Target -> Broadcast Upload Extension. This extension was then displayed in the picker.

ReplayKit's RPSystemBroadcastPickerView not showing preferredExtension

I think it is the apple's bug, but it was fixed in iOS 12.2 after I tested it.



Related Topics



Leave a reply



Submit