Posts

Post not yet marked as solved
2 Replies
681 Views
I am subclassing ARView. I'm seeing the following crash on Firebase during initialization. Unfortunately I can't reproduce it locally so I don't really know what is going on. All the devices are running iOS 15. Most of the devices have < 60 MB available RAM but not all, a few have more. It doesn't smell like a memory issue, but I mention it here... has anyone seen this? It crashes in this thread: Crashed: com.apple.root.default-qos EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000arrow_right 0 CoreRE re::CompoundShape::~CompoundShape() + 168 1 CoreRE re::CompoundShape::~CompoundShape() + 148 2 CoreRE re::CollisionShapeAssetLoader::unloadAsset(void*) + 176 3 CoreRE re::internal::AssetBackgroundLoader::unloadAsset(re::internal::AssetLoadItem&) + 168 4 CoreRE re::internal::AssetBackgroundLoader::runIfNeeded(re::internal::AssetLoadItem&) + 88 after starting on the main three: com.apple.main-thread0 ARKitCore +[ARSession setRenderType:] + 1022 2RealityKit ARView.init(frame:cameraMode:automaticallyConfigureSession:) + 740
Posted
by spiff.
Last updated
.
Post not yet marked as solved
1 Replies
1k Views
I am presenting a list of Items which are sections by the categoryIdentifier property. My app uses CloudKit. When I add change the categoryIdentifier for an item it is display in the correct section and other running instances of the app do the same. When restarting the app some items are grouped under an incorrect section, but the cstegoryIdentifier within the item is still as it was set. My question is what I'm doing wrong that upon restart the organization is incorrect. In case it matters, I'm setting this in the container:         container.viewContext.automaticallyMergesChangesFromParent = true As an aside: It seems necessary to make the sectioning type optional (as is the case in the underlying entity) like this SectionedFetchResults<String?, Item> Though the examples don't seem to need this. struct ContentView: View {     @Environment(\.managedObjectContext) private var viewContext     @State private var isShowingItem = false     @State private var isAddingItem = false          @SectionedFetchRequest(         sectionIdentifier: \.categoryIdentifier,         sortDescriptors: [NSSortDescriptor(keyPath: \Item.name, ascending: true)],         animation: .default) private var sectionedItems: SectionedFetchResults<String?, Item>          var body: some View {         NavigationView {             List {                 ForEach(sectionedItems) { section in                     Section(header: Text(Category.nameForId(section.id, context: viewContext)).font(.headline)) {                         ForEach(section) { item in                             NavigationLink(destination: ItemInputView(item: item, category: Category.get(identifier: item.category, context: viewContext))) {                                 Text(item.getName())                             }                         }                     }                 }             }                          .navigationTitle("Foo")             .sheet(isPresented: $isAddingItem) {                 ItemInputView(item: nil, category: Category.getDefault(context: viewContext))             }         }         .navigationViewStyle(.stack)     } }
Posted
by spiff.
Last updated
.
Post not yet marked as solved
1 Replies
466 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.3k 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
1.1k 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
1k Views
Hi, I've constructed a NWListener closely based on the example provided here: https://developer.apple.com/forums/thread/653925?login=true&amp;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() { &#9;&#9;&#9;&#9;do { &#9;&#9;&#9;&#9;&#9;&#9;let tcpOption = NWProtocolTCP.Options() &#9;&#9;&#9;&#9;&#9;&#9;tcpOption.enableKeepalive = true &#9;&#9;&#9;&#9;&#9;&#9;tcpOption.keepaliveIdle = 2 &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;let params = NWParameters(tls: nil, tcp: tcpOption) &#9;&#9;&#9;&#9;&#9;&#9;params.includePeerToPeer = true &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;let listener = try NWListener(using: params) &#9;&#9;&#9;&#9;&#9;&#9;networkListener = listener &#9;&#9;&#9;&#9;&#9;&#9;listener.service = NWListener.Service(name: NetworkConstants.serviceName, type: NetworkConstants.serviceType) &#9;&#9;&#9;&#9;&#9;&#9;listener.newConnectionLimit = NWListener.InfiniteConnectionLimit &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;listener.stateUpdateHandler = { [weak self] newState in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;guard let strongSelf = self else { return } &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;switch newState { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;case .ready: &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let listenerMessage = "listening on \(NetworkConstants.serviceName) \(NetworkConstants.serviceType) \(String(describing: strongSelf.networkListener!.port))" &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;strongSelf.networkDelegate?.didReceiveListenerUpdate(listener: strongSelf, didUpdateMessage: listenerMessage) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;case .failed(let error): &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;strongSelf.networkListener?.cancel() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;if strongSelf.didListenerFail { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print("listener did fail") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;strongSelf.didListenerFail = true &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NetworkListener.shared.startListener() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} else { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let errorMessage = "Listener - failed with \(error.localizedDescription), restarting" &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;strongSelf.networkDelegate?.didReceiveListenerUpdate(listener: strongSelf, didUpdateMessage: errorMessage) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;default: &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print("listener: unhandled state \(newState)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;break &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;listener.newConnectionHandler = { [weak self] newConnection in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;guard let strongSelf = self else { return } &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;strongSelf.networkDelegate?.didReceiveListenerUpdate(listener: strongSelf, didUpdateMessage: "Listener received a new connection") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;strongSelf.networkDelegate?.didReceiveNewConnection(listener: strongSelf, newConnection: newConnection) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;listener.start(queue: .main) &#9;&#9;&#9;&#9;} catch { &#9;&#9;&#9;&#9;&#9;&#9;print("Can't make listener: \(error.localizedDescription)") &#9;&#9;&#9;&#9;} &#9;&#9;} 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
1.9k 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 { &#9;&#9;var publisher = PassthroughSubject&lt;Data, NWError&gt;() &#9;&#9; &#9;&#9;private var connection: NWConnection? = nil &#9;&#9;let listener: NWListener &#9;&#9; &#9;&#9;init() { &#9;&#9;&#9;&#9;listener = try! NWListener(using: .tcp) &#9;&#9;} &#9;&#9; &#9;&#9;func report(_ msg: String) { &#9;&#9;&#9;&#9;print("server: \(msg)") &#9;&#9;} &#9;&#9; &#9;&#9;func start() throws { &#9;&#9;&#9;&#9;report("start server") &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;listener.service = NWListener.Service(name: bonjourName, type: bonjourService, domain: nil) &#9;&#9;&#9;&#9;listener.stateUpdateHandler = self.stateDidChange(to:) &#9;&#9;&#9;&#9;listener.newConnectionHandler = self.didAccept(nwConnection:) &#9;&#9;&#9;&#9;listener.serviceRegistrationUpdateHandler = self.serviceRegistrationUpdateHandler &#9;&#9;&#9;&#9;listener.start(queue: .main) &#9;&#9;} &#9;&#9; &#9;&#9;private func stateDidChange(to newState: NWListener.State) { &#9;&#9;&#9;&#9;switch newState { &#9;&#9;&#9;&#9;case .ready: &#9;&#9;&#9;&#9;&#9;&#9;report("Server ready service=\(listener.service) port=\(listener.port)") &#9;&#9;&#9;&#9;case .failed(let error): &#9;&#9;&#9;&#9;&#9;&#9;report("Server failure, error: \(error.localizedDescription)") &#9;&#9;&#9;&#9;&#9;&#9;publisher.send(completion: Subscribers.Completion.failure(error)) &#9;&#9;&#9;&#9;default: &#9;&#9;&#9;&#9;&#9;&#9;break &#9;&#9;&#9;&#9;} &#9;&#9;} &#9;&#9; &#9;&#9;private func serviceRegistrationUpdateHandler(_ change: NWListener.ServiceRegistrationChange) { &#9;&#9;&#9;&#9;report("registration did change: \(change)") &#9;&#9;} &#9;&#9; &#9;&#9;private func didAccept(nwConnection: NWConnection) { &#9;&#9;&#9;&#9;report("did accept connection: \(nwConnection)") &#9;&#9;&#9;&#9;connection = nwConnection &#9;&#9;&#9;&#9;connection?.stateUpdateHandler = self.stateDidChange &#9;&#9;&#9;&#9;connection?.start(queue: .main) &#9;&#9;&#9;&#9;receive() &#9;&#9;} &#9;&#9;private func stateDidChange(to state: NWConnection.State) { &#9;&#9;&#9;&#9;switch state { &#9;&#9;&#9;&#9;case .waiting(let error): &#9;&#9;&#9;&#9;&#9;&#9;publisher.send(completion: Subscribers.Completion.failure(error)) &#9;&#9;&#9;&#9;case .ready: &#9;&#9;&#9;&#9;&#9;&#9;report("connection ready") &#9;&#9;&#9;&#9;case .failed(let error): &#9;&#9;&#9;&#9;&#9;&#9;publisher.send(completion: Subscribers.Completion.failure(error)) &#9;&#9;&#9;&#9;&#9;&#9;connectionDidFail(error: error) &#9;&#9;&#9;&#9;default: &#9;&#9;&#9;&#9;&#9;&#9;break &#9;&#9;&#9;&#9;} &#9;&#9;} &#9;&#9; &#9;&#9;// functions removed to make space &#9;&#9; &#9;&#9;private func receive() { &#9;&#9;&#9;&#9;connection?.receive(minimumIncompleteLength: 1, maximumLength: Int.max) { (data, _, isComplete, error) in &#9;&#9;&#9;&#9;&#9;&#9;if let error = error { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.report("connection failed: \(error)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.connectionDidFail(error: error) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;return &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;if let data = data, !data.isEmpty { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.report("connection did receive, data: \(data)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.publisher.send(data) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;if isComplete { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.report("is complete") //&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.connectionDidEnd() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;return &#9;&#9;&#9;&#9;&#9;&#9;} else { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.report("setup next read") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.receive() &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;} &#9;&#9;} &#9; &#9;&#9;func send(data: Data) { &#9;&#9;&#9;&#9;report("connection will send data: \(data)") &#9;&#9;&#9;&#9;self.connection?.send(content: data, contentContext: .defaultStream, completion: .contentProcessed( { error in &#9;&#9;&#9;&#9;&#9;&#9;if let error = error { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.connectionDidFail(error: error) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;return &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;self.report("connection did send, data: \(data)") &#9;&#9;&#9;&#9;})) &#9;&#9;} &#9;&#9; &#9;&#9;func sendStreamOriented(connection: NWConnection, data: Data) { &#9;&#9;&#9;&#9;connection.send(content: data, completion: .contentProcessed({ error in &#9;&#9;&#9;&#9;&#9;&#9;if let error = error { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.connectionDidFail(error: error) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;})) &#9;&#9;} }
Posted
by spiff.
Last updated
.