I am trying to use the AVCaptureVideoPreviewLayer with PiP like this:
if #available(iOS 15.0, *) {
let pipVideoCallViewController = AVPictureInPictureVideoCallViewController()
pipVideoCallViewController.preferredContentSize = CGSize(width: 160, height: 160)
pipVideoCallViewController.view.addSubview(videoView)
let pipContentSource = AVPictureInPictureController.ContentSource(
activeVideoCallSourceView: videoView,
contentViewController: pipVideoCallViewController)
let pipController = AVPictureInPictureController(contentSource: pipContentSource)
pipController.canStartPictureInPictureAutomaticallyFromInline = true
pipController.startPictureInPicture()
} else {
// Fallback on earlier versions
}
But I am receiving the following error every time I start the PiP:
-[PGPictureInPictureProxy (0x119965290) _updateAutoPIPSettingsAndNotifyRemoteObjectWithReason:] - Acquiring remote object proxy for connection <NSXPCConnection: 0x28364fca0>
connection to service with pid 64 named com.apple.pegasus failed with
error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to
service with pid 64 named com.apple.pegasus was invalidated from this
process." UserInfo={NSDebugDescription=The connection to service with
pid 64 named com.apple.pegasus was invalidated from this process.}
If I don't connect in the ContentSource, my view present the video but if I connect the layer disappears.
Related
Is Apple Watch not able to make network calls when the app is a standalone app, even though the watch is connected to an iPhone? I'm using the new standalone app target, which does not come with a paired iOS app to which WatchConnectivity requests could be made.
I'm getting "Bad file descriptor" 9 times out of 10, and this is making me think watch apps basically need an iPhone to guarantee some amount of connectivity (my watch doesn't have cellular and I can't connect to public wifi hotspots).
Am I holding this wrong?
Example code snippet to reproduce this:
import Combine
import SwiftUI
var cancellables = Set<AnyCancellable>()
#main
struct NetworkTest_Watch_AppApp: App {
var body: some Scene {
WindowGroup {
Text("Test")
.task {
let url = URL(string: "https://google.com")!
let dataTaskPublisher = URLSession.shared.dataTaskPublisher(for: url)
dataTaskPublisher
.retry(3)
.sink(receiveCompletion: { completion in
print(completion)
}, receiveValue: { response in
print(response)
})
.store(in: &cancellables)
}
}
}
}
Example log failure:
2023-01-05 22:48:54.472214-0800 NetworkTest Watch App[809:862165] [scenes] unable to send desiredFidelity:Never response to desiredFidelityAction:<BLSDesiredFidelityAction: 0x16ed9090; info: 0x0; responder: <_BSActionResponder: 0x16ed93e0; active: YES; waiting: NO> clientInvalidated = NO;
clientEncoded = NO;
clientResponded = NO;
reply = <BSMachPortSendOnceRight: 0x16ed9a90; usable: NO; (809:0:send-once xpcCode) from (779:0:send-once take)>;
annulled = YES;>
2023-01-05 22:50:14.457958-0800 NetworkTest Watch App[809:862418] PDTask <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1> finished with error [9] Error Domain=NSPOSIXErrorDomain Code=9 "Bad file descriptor" UserInfo={_kCFStreamErrorCodeKey=9, NSErrorPeerAddressKey={length = 28, bytes = 0x1c1ef516 00000000 fd746572 6d6e7573 ... cbc268fa 00000000 }, _kCFStreamErrorDomainKey=1, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataPDTask <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1>",
"LocalDataTask <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataPDTask <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1>}
2023-01-05 22:50:14.459136-0800 NetworkTest Watch App[809:862418] Task <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1> finished with error [9] Error Domain=NSPOSIXErrorDomain Code=9 "Bad file descriptor" UserInfo={_kCFStreamErrorCodeKey=9, NSErrorPeerAddressKey={length = 28, bytes = 0x1c1ef516 00000000 fd746572 6d6e7573 ... cbc268fa 00000000 }, _kCFStreamErrorDomainKey=1, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1>",
"LocalDataPDTask <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1>",
"LocalDataTask <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <42094D6F-56E0-45A9-9F47-53DB66453C9D>.<1>}
I'm trying to make NFC work on a iOS phone and now I'm getting this error:
[CoreNFC] 00000002 82426be0 -[NFCHardwareManager areFeaturesSupported:outError:]:154 XPC Error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nfcd.service.corenfc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service named com.apple.nfcd.service.corenfc was invalidated from this process.}
The package I'm currently using is nfc_manager
Here is the code that's being used:
openNFC() async {
// Check availability
bool isAvailable = await NfcManager.instance.isAvailable();
// Start Session
if (isAvailable == true) {
NfcManager.instance.startSession(
onDiscovered: (NfcTag tag) async {
print(tag);
},
);
} else {
print("Your device is not compatible with NFC");
}
// Stop Session
NfcManager.instance.stopSession();
}
Can someone please help me? Thanks in advance❤️
this is my first post to the community, so please be patient ;-)
I am using Apples Network framework to build a TCP connection to a server. It locks like this:
let testConnection = NWConnection(host: NWEndpoint.Host(server!.serverAddress), port: NWEndpoint.Port(server!.serverPort)!, using: .tcp)
testConnection.stateUpdateHandler = ({ state in
print("TCP state change to: \(state)")
switch state {
case .setup:
break
case .waiting(let error):
print("Waiting Error \(error)")
testConnection.cancel()
break
case .preparing:
break
case .ready:
beginCommunication()
break
case .failed(let error):
print("\(error)")
break
case .cancelled:
break
default:
break
}
})
The serverAddress and serverPort is entered by the user. I want to test the connection. Now my problem is, that if the user is entering an invalid address / port combination (the service is not offered by the server). I stuck in the preparing state for quite a long time. After that I get to the waiting stage (with error message POSIXErrorCode: Operation timed out).
Is there any way to set the timeout for this first connection process ?
Thanks for your ideas
You can set connection timed out by NWProtocolTCP.Options
lazy var tcpOptions: NWProtocolTCP.Options = {
let options = NWProtocolTCP.Options()
options.connectionTimeout = 5 // connection timed out
return options
}()
lazy var parames: NWParameters = {
let parames = NWParameters(tls: nil, tcp: self.tcpOptions)
if let isOption = parames.defaultProtocolStack.internetProtocol as? NWProtocolIP.Options {
isOption.version = .v4
}
parames.preferNoProxies = true
return parames
}()
lazy var connection: NWConnection = {
let connection = NWConnection(host: "x.x.x.x", port: xxxx, using: self.parames)
return connection
}()
When trigger the timed out event, the .waiting state will call back.
2021-08-30 23:05:17.xxxxxx+xxxx Demo[xxxx:xxxxxx] [connection] nw_socket_handle_socket_event [C1:1] Socket SO_ERROR [60: Operation timed out]
The connection is waiting for a network path change with: POSIXErrorCode: Operation timed out
reference from Developer Fourms
Im getting the error in the title when I run my app. I am running Xcode Beta 10 Version 6. The full error is:
[NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 “The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.” UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
It gets thrown in my createTaskFromSnapshot() function, on the first line of the function.
My code:
func observeDatabase(_ tableToUpdate: UITableView) {
taskDatabase.observe(.childAdded) { (snapshot) in
self.handleChildAdded(snapshot: snapshot)
tableToUpdate.reloadData()
}
}
private func handleChildAdded(snapshot:
let addedTask = createTaskFromSnapshot(snapshot)
taskList.append(addedTask)
}
private func createTaskFromSnapshot(_ snapshot: DataSnapshot) -> Task {
let snapshotValue = snapshot.value as! Dictionary<String, String> // error is thrown here
let taskTitle = snapshotValue["taskTitle"]!
let newTask = Task(title: taskTitle)
return newTask
}
What does this error mean? and why am I getting it?
The message is probably unrelated to the crash/issue.
I've had this message bother me for a while now with no way of removing it.
Well I've found a way to hide this in your xcode console just run one of the following command in a terminal:
xcrun simctl spawn booted log config --mode "level:off" --subsystem com.apple.CoreTelephony
sudo log config --mode "level:off" --subsystem com.apple.CoreTelephony
you can always re-enable this at anytime by running the same command with a different level attribute`
Try this:
1- From Xcode menu open: Product > Scheme > Edit Scheme
2- On your Environment Variables set OS_ACTIVITY_MODE = disable
In my case this type of warning was generated in the case when CTTelephonyNetworkInfo() was used. As this error only generated on simulator I did like this:
#if targetEnvironment(simulator)
return []
#else
let networkInfo = CTTelephonyNetworkInfo()
return [networkInfo.subscriberCellularProvider]
#endif
Test Use Case:
In my scenario, I initialize my App in Xcode, login to firebase and run my app
successfully. I then stop the debugger in Xcode, and then "turn Wifi off" on
my MAC. I then initialize my App again in Xcode.
In the debugger, I see my code initialize an authentication listener and
initialize based on the previously cached value of authenticated user information.
I also see the following exception in the console log.
2017-06-02 09:29:21.281 MusicPoll[7053] [Firebase/Core][I-NET901017] Encounter network error. Code, error: -1009, Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x60800005f7d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorFailingURLKey=https://play.googleapis.com/log, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}
Since I am not connected to the network, I would like to detect this
condition and ask the user to check his/her network connection and try again.
My question is which Firebase method should I used to check network connectivity and perhaps obtain an error. (I am unable to find an error code that might be
returned in the listener's callback.)
My Code:
...
fileprivate var authListener : FIRAuthStateDidChangeListenerHandle!
FUIAuth.defaultAuthUI()?.providers = [FUIGoogleAuth()]
authListener = FIRAuth.auth()?.addStateDidChangeListener { [weak self] (auth: FIRAuth, user: FIRUser?) in
guard let strongSelf = self else { return }
if let activeUser = user {
strongSelf.hasUserBeenAuthenticated = true
strongSelf.user = activeUser
} else {
strongSelf.hasUserBeenAuthenticated = false
strongSelf.user = nil
}
print("\nFirebaseMgr[setupAuthorization]: hasUserBeenAuthenticated = \(strongSelf.hasUserBeenAuthenticated), user = \(String(describing: strongSelf.user))")
}
You can check the status of the user's internet connection using Firebase's FIRDatabase.database().reference(withPath: ".info/connected") method. This method will observe any changes in network connectivity. Here is an example:
//this is a strong reference to the internet connection handle
var internetConnectionHandle: UInt!
//I have created the observer for internet connectivity in viewWillAppear
override func viewWillAppear(_ animated:Bool) {
let connectedRef = FIRDatabase.database().reference(withPath: ".info/connected")
internetConnectionHandle = connectedRef.observe(.value, with: { snapshot in
if let _ = snapshot.value as? Bool {
//use is connected to the internet.
}
else {
//user is not connected to the internet. Ask the user to check his/her network connection and try again
}
})