Post

Replies

Boosts

Views

Activity

Class 'ARCollaborationData' disallows secure coding.
Hey everyone, I have an app that offers collaboration in AR and I was following the docs on how to send ARSession.CollaborationData using MultipeerConnectivity. https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration/3152987-iscollaborationenabled It appears that, with iOS 14, that is no longer possible. I receive the following error when I try to unarchive: Class 'ARCollaborationData' disallows secure coding. It must return YES from supportsSecureCoding. I'm more or less using the exact some code as given in the documentation and it worked flawlessly with iOS 13. Now, with iOS 14, I am not sure how to fix this issue. I've tried sending it with requiringSecureCoding: false as well as trying to create an NSKeyedUnarchiver which doesn't has requiresSecureCoding set to false as well. As far as I'm aware, I'm not able to change the implementation of NSSecureCoding for ARSessioin.CollaborationData (which is supposedly present anyway). Has anyone else had this issue before? Could it be that this is a bug and I just have to report it and wait? Either way, thanks in advance for any hints or tips :) They are greatly appreciated! Best regards, Bjoern
0
0
636
Sep ’20
`DispatchQueue.main.async` seems to get bogged down periodically
Hi everyone, I have an AR app that allows for collaborative sessions and synchronizes model state (e.g. rotation, can be changed via slider) using Multipeer Connectivity. The receiving peer parses the data and then uses DispatchQueue.main.async to update the UI (SwiftUI) and the model in SceneKit. Lately I have noticed that this synchronization seems to lag periodically. To analyze the issue better I compiled this minimal reproducible example: https://github.com/MrMuetze/MCSyncTest The repository includes a boiled down "Multipeer Connectivity" project that should make this issue reproducible on local devices (maybe even between one device and the simulator). I have also added a readme with a gif that shows the issue. The synchronization between devices worked like a treat for a long time but recently I have noticed that e.g. a rotation is not as smooth as before on the receiving device. A bit of debugging revealed that the messages are received quickly but then the work that needs to happen on the main thread is periodically delayed. In the example project the relevant code bit that should be executed on the main thread looks like this: func session(_: MCSession, didReceive data: Data, fromPeer _: MCPeerID) { print("received data") DispatchQueue.main.async { print("doing stuff") let doubleVal = data.to(type: Double.self) ?? 0.0 self.internalSliderValue = doubleVal self.sliderValue = doubleVal } } It updates a published variable sliderValue that is connected to a Slider and a Text UI element. Regularly (like every 500ms or so) the execution of work on the main thread seems to be delayed. After a short while all outstanding UI updates are executed at once which leads to visual stuttering. This can be observed by looking at the printed messages: ... received data <-- normal behavior doing stuff received data doing stuff received data doing stuff received data <-- hiccup starts received data received data received data doing stuff doing stuff doing stuff doing stuff received data <-- returns to normal behavior doing stuff received data doing stuff ... I have tried to change the "Quality of Service" to .userInteractive as well as limiting the number of messages that are sent in a certain timeframe (I tried one message every 100ms). Both changes have not helped and even with a much lower number of messages the periodic stuttering remains. Using DispatchQueue.main.sync is also not a solution right now. It does bring the sequence back into original order but the periodic "freeze" of the queue is prevalent there as well. This then leads to a "laggy" execution of what happened on the sending peer device. I am not very familiar with Profiling an app and using Instruments, but I have captured some timings in regards to the usage of the main thread and some backtraces. From what I can understand the workload of the written code should not be the issue, but rather an underlying system function or library. I can provide more information in regards to the backtraces if needed. Right now I can't really say what would be useful. Below is an image that shows the main thread usage at the very top. This happens when the slider lags as shown in the gif. I am working with Xcode 15.2 and run the app on iOS 17.3. For devices I use an iPad Pro (2nd gen.) and an iPhone 15 Pro. The issue happens in Debug as well as in Release mode. I can't quite say when the stuttering appeared initially. I wonder if anyone is aware of any changes to iOS or underlying frameworks that could have caused this issue. I am interested in any information about this, if the issue can be resolved or if I have to look for alternative workarounds. Let me know if I can add any additional information. Best regards! Bjoern
0
0
851
Feb ’24