Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 14 Circular Reference when using SelfRecordable extension methods #54

Closed
rogerioth opened this issue Oct 1, 2022 · 4 comments
Closed

Comments

@rogerioth
Copy link

Possibly a resurgence of #51

I'm using the latest 2.8.0 version, with clean Derived Data, and Podfile.lock

The IDE is not pinpointing the precise location of the circular reference:

Screen Shot 2022-10-01 at 1 10 53 AM

Below is a shortened version of the class:

import Foundation
import SCNRecorder
import AVKit
import AVFoundation
import AssetsLibrary

@objc public class SurfaceRecorder: NSObject {
    private var audioRecorder: AVAudioRecorder? =  nil
    private var audioURL: URL? = nil
    private var methodBCaptureSession: AVCaptureSession? = nil
    private var connection : AVCaptureConnection?
    private var fileOutput: AVCaptureMovieFileOutput?
    private var fileOutputURL: URL? = nil
    
    private var IARView: IARSurfaceView? = nil
    
    private var view: SCNView {
        guard let view = IARView?.internalSceneView() else {
            fatalError("Recording methods should be called after SurfaceView.load() method")
        }
        return view
    }

    // MARK: - Private Methods
    
    (...)
    
    private func startVideoRecording() -> NSError? {
        FileLogger.shared.log(content: "Recording started...")

        view.prepareForRecording()
        
        do {
            try view.startVideoRecording()
        } catch {
            FileLogger.shared.log(content: "Failed to start recording: \(error.localizedDescription)")
            return NSError.error(from: error)
        }
        
        return nil
    }
    
    (...)
    
    @objc public func stopRecording(finalFileName: String?, completionHandler handler: @escaping (NSURL?, Error?) -> Void) {
        
        if let audioRecorder = audioRecorder {
            audioRecorder.stop()
        }
        
        guard let audioURL = audioURL else {
            handler(nil, nsError(withText: "Failed to obtain audio file URL", code: IARErrorCode.errorRecordVideo))
            return
        }
        
        view.finishVideoRecording { [weak self] (videoRecording) in
            (...)
        }
    }
}

Circular references are likely to be caused by these lines:

        view.prepareForRecording()

       // and
        
        do {
            try view.startVideoRecording()

       // and

        view.finishVideoRecording { [weak self] (videoRecording) in

any advices?

@amir-cg
Copy link
Contributor

amir-cg commented Oct 24, 2022

I've having the same issue!
Is there a workaround?

@amir-cg
Copy link
Contributor

amir-cg commented Oct 24, 2022

I've created a pull request that fixes this issue:
#55

@v-grigoriev
Copy link
Collaborator

The PR is merged, I will make a release later today.

@v-grigoriev
Copy link
Collaborator

released.
Please do pod repo update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants