Posts

Post not yet marked as solved
1 Replies
342 Views
Hi, after rotating the iPad ARCamera.trackingState transitions to .initilizing and the video freezes. The application as a whole still functions. I'm unable to extract a relevant code example as this is embedded in a larger application. I am not seeing this behavior on iPhone. Is there any possibility that this is related to layout constraints? I see some warnings when the rotation occurs. Is there anything else I might examine? Thank you
Posted
by spiff.
Last updated
.
Post not yet marked as solved
7 Replies
1.1k Views
I'm trying to render a MKPolyline on tvOS and get a runtime exception with _validateTextureView:531: failed assertion `cannot create View from Memoryless texture.' This same code works fine on the iPad and I'm starting to think it just doesn't work on tvOS...unless this is a beta issue.
Posted
by spiff.
Last updated
.
Post not yet marked as solved
1 Replies
524 Views
Hi, why doesn't this view scroll? The image is taller than the screen. struct ImageScroll: View {     @State var uiImage: UIImage     var body: some View {         ScrollView {             Image(uiImage: uiImage)                 .focusable()         }         .focusable()     } } Thanks, Spiff
Posted
by spiff.
Last updated
.
Post not yet marked as solved
4 Replies
572 Views
Hi, I've constructed a NWListener closely based on the example provided here: https://developer.apple.com/forums/thread/653925?login=true&page=1#621284022 The problem is that the example specifically only handles a single connection request and then ignores all others. I've removed that logic. The problem is that for code running on two simulators (tvOS and iOS) I get four accepts each time I connect from the client. They are coming in pairs of ipv4/ipv6. The second address might be the simulator,.0.5 is the mac. I need to implement a server that accepts as many connections over time as needed. My questions are a) can I only listen on one protocol, for example ipv6 only? b) if not how should I ignore the other connection? I don't seem to get information into newConnectionHandler, which is too late. c) why am I getting a second pair of connections? Thanks in advance for your help! Cliff func startListener() { 				do { 						let tcpOption = NWProtocolTCP.Options() 						tcpOption.enableKeepalive = true 						tcpOption.keepaliveIdle = 2 						 						let params = NWParameters(tls: nil, tcp: tcpOption) 						params.includePeerToPeer = true 						 						let listener = try NWListener(using: params) 						networkListener = listener 						listener.service = NWListener.Service(name: NetworkConstants.serviceName, type: NetworkConstants.serviceType) 						listener.newConnectionLimit = NWListener.InfiniteConnectionLimit 						 						listener.stateUpdateHandler = { [weak self] newState in 								guard let strongSelf = self else { return } 								switch newState { 								case .ready: 										let listenerMessage = "listening on \(NetworkConstants.serviceName) \(NetworkConstants.serviceType) \(String(describing: strongSelf.networkListener!.port))" 										strongSelf.networkDelegate?.didReceiveListenerUpdate(listener: strongSelf, didUpdateMessage: listenerMessage) 								case .failed(let error): 										strongSelf.networkListener?.cancel() 										if strongSelf.didListenerFail { 												print("listener did fail") 												strongSelf.didListenerFail = true 												NetworkListener.shared.startListener() 										} else { 												let errorMessage = "Listener - failed with \(error.localizedDescription), restarting" 												strongSelf.networkDelegate?.didReceiveListenerUpdate(listener: strongSelf, didUpdateMessage: errorMessage) 										} 								default: 										print("listener: unhandled state \(newState)") 										break 								} 						} 						 						listener.newConnectionHandler = { [weak self] newConnection in 								guard let strongSelf = self else { return } 								strongSelf.networkDelegate?.didReceiveListenerUpdate(listener: strongSelf, didUpdateMessage: "Listener received a new connection") 								strongSelf.networkDelegate?.didReceiveNewConnection(listener: strongSelf, newConnection: newConnection) 						} 						 						listener.start(queue: .main) 				} catch { 						print("Can't make listener: \(error.localizedDescription)") 				} 		} listener: ScreenshotServer.NetworkListener: Listener received a new connection listener: ScreenshotServer.NetworkListener: new connection [C1 ::1.52396 tcp, local: ::1.52309, server, prohibit joining, path satisfied (Path is satisfied), interface: lo0] listener: ScreenshotServer.NetworkListener: Listener received a new connection listener: ScreenshotServer.NetworkListener: new connection [C2 192.168.0.5:52397 tcp, local: 192.168.0.5:52309, server, prohibit joining, path satisfied (Path is satisfied), interface: lo0] listener: ScreenshotServer.NetworkListener: Listener received a new connection listener: ScreenshotServer.NetworkListener: new connection [C3 192.168.0.2:52398 tcp, local: 192.168.0.2:52309, server, prohibit joining, path satisfied (Path is satisfied), interface: lo0] listener: ScreenshotServer.NetworkListener: Listener received a new connection listener: ScreenshotServer.NetworkListener: new connection [C4 169.254.240.25:52399 tcp, local: 169.254.240.25:52309, server, prohibit joining, path satisfied (Path is satisfied), interface: lo0]
Posted
by spiff.
Last updated
.
Post not yet marked as solved
7 Replies
956 Views
I’m pulling out my hair trying to reverse-engineer the more-or-less undocumented Network framework. It appears that two things are happening, one is that the listener is accepting two connection requests, one on ipv4 and one on ipv6. Secondly, it seems that the the connection immediately sets isComplete. Also, what does prohibit joining mean in the connection? server: did accept connection: [C1 ::1.63423 tcp, local: ::1.63406, server, prohibit joining, path satisfied (Path is satisfied), interface: lo0] It sure would be nice to have more examples of this framework in action, it feels like Apple is not really committed to it and that worries me. class Server { 		var publisher = PassthroughSubject<Data, NWError>() 		 		private var connection: NWConnection? = nil 		let listener: NWListener 		 		init() { 				listener = try! NWListener(using: .tcp) 		} 		 		func report(_ msg: String) { 				print("server: \(msg)") 		} 		 		func start() throws { 				report("start server") 				 				listener.service = NWListener.Service(name: bonjourName, type: bonjourService, domain: nil) 				listener.stateUpdateHandler = self.stateDidChange(to:) 				listener.newConnectionHandler = self.didAccept(nwConnection:) 				listener.serviceRegistrationUpdateHandler = self.serviceRegistrationUpdateHandler 				listener.start(queue: .main) 		} 		 		private func stateDidChange(to newState: NWListener.State) { 				switch newState { 				case .ready: 						report("Server ready service=\(listener.service) port=\(listener.port)") 				case .failed(let error): 						report("Server failure, error: \(error.localizedDescription)") 						publisher.send(completion: Subscribers.Completion.failure(error)) 				default: 						break 				} 		} 		 		private func serviceRegistrationUpdateHandler(_ change: NWListener.ServiceRegistrationChange) { 				report("registration did change: \(change)") 		} 		 		private func didAccept(nwConnection: NWConnection) { 				report("did accept connection: \(nwConnection)") 				connection = nwConnection 				connection?.stateUpdateHandler = self.stateDidChange 				connection?.start(queue: .main) 				receive() 		} 		private func stateDidChange(to state: NWConnection.State) { 				switch state { 				case .waiting(let error): 						publisher.send(completion: Subscribers.Completion.failure(error)) 				case .ready: 						report("connection ready") 				case .failed(let error): 						publisher.send(completion: Subscribers.Completion.failure(error)) 						connectionDidFail(error: error) 				default: 						break 				} 		} 		 		// functions removed to make space 		 		private func receive() { 				connection?.receive(minimumIncompleteLength: 1, maximumLength: Int.max) { (data, _, isComplete, error) in 						if let error = error { 								self.report("connection failed: \(error)") 								self.connectionDidFail(error: error) 								return 						} 						 						if let data = data, !data.isEmpty { 								self.report("connection did receive, data: \(data)") 								self.publisher.send(data) 						} 						if isComplete { 								self.report("is complete") //								self.connectionDidEnd() 								return 						} else { 								self.report("setup next read") 								self.receive() 						} 				} 		} 	 		func send(data: Data) { 				report("connection will send data: \(data)") 				self.connection?.send(content: data, contentContext: .defaultStream, completion: .contentProcessed( { error in 						if let error = error { 								self.connectionDidFail(error: error) 								return 						} 						self.report("connection did send, data: \(data)") 				})) 		} 		 		func sendStreamOriented(connection: NWConnection, data: Data) { 				connection.send(content: data, completion: .contentProcessed({ error in 						if let error = error { 								self.connectionDidFail(error: error) 						} 				})) 		} }
Posted
by spiff.
Last updated
.