Takeshi Yokemura
Takeshi Yokemura

Reputation: 425

ReplayKit fails to record

I'm developing an app with screen capturing feature.

ReplayKit is pretty simple and it works very well, but while I was testing it many times of recording it suddenly got to fail recording.

When it fails, it just shows an empty black video on the preview view. No crash, no error message.

I had doubts on my own code (although the implementation of ReplayKit is super simple), so I tried with a simple sample code from here https://code.tutsplus.com/tutorials/ios-9-an-introduction-to-replaykit--cms-25458 and found the issue still happens.

I've found this Q&A and tried to discard recordings before starting a new recording but it didn't work. https://forums.developer.apple.com/thread/24613

I also found that although it fails recording at its first try(I mean right after launching the app) but it succeeds on the second try.

So I'm guessing that my system is run out of a sort of system-wide resource and the cleanup for that only happens after recording or something like that but I have no clue to research into detail because ReplayKit is so closed and only provides the very limited access to its data.

The only irregular thing I did is, that I did an experiment to retrieve the video data directly with this code. I did this many time so if this code has a problem the impact might be big.

[[RPScreenRecorder sharedRecorder] stopRecordingWithHandler:^(RPPreviewViewController * _Nullable previewViewController, NSError * _Nullable error) {

    NSURL* screenCaptureVideoURL = [previewViewController valueForKey:@"movieURL"];
    [self saveCaptureVideoToCameraRoll:screenCaptureVideoURL]; // My own routine to save the video to camera roll

}];

Are there anybody else who are facing the same issue? Any solution to it?

Any info is appreciated. Thanks.

Upvotes: 0

Views: 1571

Answers (1)

Andrew
Andrew

Reputation: 36

I was having a similar issue and it turned out that using AVPlayer was the cause of black screens being returned on the preview controller. I think it might be a DRM feature and not a bug of replayKit because the documentation mentions that you can't record AVPlayer content.

Are you using AVPlayer for anything?

Upvotes: 2

Related Questions