Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange error nw_protocol_get_quic_image_block_invoke dlopen libquic failed

Tags:

swift

I'm new to swift and iOS in general, please keep that in mind.

I get this error when opening the CFReadStream. It does not matter if I open the read or write streams, the app always fails.

    var readStream: Unmanaged<CFReadStream>?     var writeStream: Unmanaged<CFWriteStream>?     let host: CFString = NSString(string: hostIP)     let port: UInt32 = UInt32(self.VNCport)          self.password = password          CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, host, port, &readStream, &writeStream)      inputStream = readStream!.takeRetainedValue()     outputStream = writeStream!.takeRetainedValue()          if readStream == nil {         print("Erro read")     }          if writeStream == nil {         print("Erro write")     }          inputStream!.delegate = self     outputStream!.delegate = self          inputStream!.schedule(in: RunLoop.main, forMode: RunLoop.Mode.default)     outputStream!.schedule(in: RunLoop.main, forMode: RunLoop.Mode.default)     inputStream!.open()     outputStream!.open() 

I made a clean project with just this function and a Button, the result is the same. No quic lib is used in the project.

Can someone help?

like image 655
coives Avatar asked Sep 23 '20 14:09

coives


Video Answer


1 Answers

I faced the same error in a different context, in XCode 12.0.1 too. It might not be related, but I suspect its an issue with accessing the run loop of the main thread. I was just trying out some introductory code I found online, and faced the same issue, so this is a bug, rather than a problem with your code. Here's how you can get a piece of code that has the same issue:

git clone [email protected]:BestKora/CS193P-Fall-2017-Demo-iOS12.git cd "CS193P-Fall-2017-Demo-iOS12/Cassini L10" xed . # this opens XCode (CLI tool stands for XCode editor) 

Having said that, by rewriting the code, I was able to prevent this issue. Maybe you can find something amongst the code below to fix your specific issue:

Specifically, instead of using the following (DispatchQueue.global)

    private func fetchImage() {         if let url = imageURL {             spinner.startAnimating()             DispatchQueue.global(qos: .userInitiated).async { [weak self] in                 let urlContents = try? Data(contentsOf: url)                 DispatchQueue.main.async {                     if let imageData = urlContents, url == self?.imageURL {                         self?.image = UIImage(data: imageData)                     }                 }             }         }     } 

I use URLSession.shared.dataTask, and this error no longer happens:

    private func fetchImage() {         print("fetching image")         if let url = imageURL {                          let task = URLSession.shared.dataTask(with: url) {(data, response, error) in                 guard let data = data else {                     return                 }                 // maybe try dispatch to main                 DispatchQueue.main.async {                     self.imageView.image = UIImage(data: data)                 }             }             task.resume()         }     } 
like image 120
Ben Butterworth Avatar answered Oct 15 '22 01:10

Ben Butterworth