Pause ARSession broken in 17.4

I have a tracking issung with the latest beta 17.4 and want to know if anyone encountered the same problem.

My app is using the pause=false functionality for multiroom that apple provided to let the ARSession run in the background:

    roomCaptureView?.captureSession.stop(pauseARSession: false)

When resuming the scan/scanning the next room I initialize a new RoomCaptureView with the running ARSession:

        let roomCaptureView = RoomCaptureView(frame: rcvc.view.bounds, arSession: arSession!)

This worked fine on all previous versions and different devices. Since the update to 17.4 I noticed that the tracking will be lost after initializing the next scan which feels like the pauseARSession is not working (the ARSession has still the same ID)

Devices: This behaviour/error does not occur on devices with 17.3 or lower: 15 Pro Max, 14 Pro Max, 13 Pro This behaviour/error occures on devices with 17.4: 15 Pro Max, 14 Pro Max

If anyone has noticed the same issue I would like to know that I'm not the only one. Thanks.

Answered by JohnnyBanana in 781207022

Ok it seems like the issue was caused by the RoomCaptureView. I called roomCaptureView?.removeFromSuperview() after every finished room and when starting the next room I added it again to the view controller with roomCaptureViewConrtoller.view.insertSubview(roomCaptureView, at: 0).

It seems like this was not an issue in versions < iOS 17.4 beta but apparently you have to keep the view attached to the view controller and the multiroom works as in previous versions.

I am seeing something similar and other strangeness. After running for a while I am seeing a multitude of AR Sessions populating my Self stack and don't know from where they are coming! I put a breakpoint in the SessionwasInterrupted code in my delegate and I had 3 new AR Sessions show up in the Self stack in various objects for Thread 1 and one matched an entry for the stack object arSession . I took down the pointers to the stack and took screenshots of the memory layout in the frames of self. So then I went on and let it finish the SessionWasInterrupted only to have it jump into another with a whole NEW set of ARSession carcasses lying around in the Self Stack frame that was active and only one of them matched the arSession again and Was not the same as the previous one.

I have seen this and other strangeness in the handling of ARSessions

Accepted Answer

Ok it seems like the issue was caused by the RoomCaptureView. I called roomCaptureView?.removeFromSuperview() after every finished room and when starting the next room I added it again to the view controller with roomCaptureViewConrtoller.view.insertSubview(roomCaptureView, at: 0).

It seems like this was not an issue in versions < iOS 17.4 beta but apparently you have to keep the view attached to the view controller and the multiroom works as in previous versions.

I have also been facing a similar issue, but never had the chance to test it in 17.3. Our app allows a user to scan a room and then save that scan on a separate view, followed by additional scans. We're looking into allowing room combining via CapturedStructure, so we need rooms to be scanned in the same ARWorldMap without necessarily needing to re-localize in the same session.

This bring us to this issue - the only way I have found that allows our requirements is to save RoomCaptureView and to re-use that RoomCaptureView whenever we need to start a session again. This creates a number of other issues, and ideally, we wouldn't need to save a View in something like a singleton. We are using captureSession.stop(pauseARSession: false).

Saving the ARSession and using it in let roomCaptureView = RoomCaptureView(frame: viewBounds, arSession: arSession) where we're creating a new view with the same ARSession seems much more ideal, but just like this issue stated, world tracking seems to be completely lost when a new RoomCaptureView (and thus a new RoomCaptureSession) is started, even with the same already started ARSession.

Is there any way around needing to use the same RoomCaptureView or RoomCaptureSession for subsequent scans in the same session without needing to re-localize via ARWorldMap loading?

Pause ARSession broken in 17.4
 
 
Q