Guided Capture sample - broken with iOS17 beta 4

Sample project from: https://developer.apple.com/documentation/RealityKit/guided-capture-sample was fine with beta 3.

In beta 4, getting these errors: Generic struct 'ObservedObject' requires that 'ObjectCaptureSession' conform to 'ObservableObject'

Does anyone have a fix?

Thanks

Yes, actually its not that hard to fix. The object capture session is not an observed object anymore, but the AppDataModel (which the ObjectCaptureSession is in) is an environment object. Just remove the @ObservableObject ObjectCaptureSession anywhere and use the @Environment AppDataModel and access it from there.

You also have to rewrite the feedback and state sink in the AppDataModel because they are also not published anymore. Use the "ObjectCaptureSession.feedbackUpdates / ObjectCaptureSession.stateUpdates" for that.

Hope i could help, this took me a day to figure out yesterday.

Even with these fixes, there is a crash when reconstructing a lot of pictures: Assert: in line 204

On a smaller batch of pictures it works

I have the same issue, but - at least in my case - it has nothing to do with the amount of pictures. It did also crash one time with just 10 images.

Does someone know something about this issue?

The past betas there was issues with Metal that causes a lot of crashes for us. I was hoping this would be fixed in this release. I have to say it has been rather disappointing on how Apple has rolled out these new features so far. First it took 1 month for the sample code to land and then there was multiple issues with memory usage and performance on early betas. and then they entirely changed to the Observable Object Framework without any notice and or updating their sample code.

@NavidF If we use @Environment AppDataModel.... AppDataModel need to adopt @Observable macro and I believe @Observable macro is not working with Xcode 15 beta 5.

@mayur_tanna Why should we need the @Observable macro? I have the AppDataModel as ObservableObject and everything works for my on the scanning side. I just now get more and more crashes when it comes to reconstruction.

We switched ObjectCaptureSession to use the new Observation (https://developer.apple.com/videos/play/wwdc2023/10149/) feature. Unfortunately, the sample code update was not released at the same time as the API change and we apologize for the inconvenience this caused. The new sample code that switches to the new Observation feature is available now.

As noted, ObjectCaptureSession no longer uses the Combine ObservableObject which means all SwiftUI usage points no longer need @ObservedObject (as the WWDC session above describes). We highly recommend storing the session in a ground truth model class for maximal control of its lifecycle and passing it by reference as needed to SwiftUI views. As the Observation session points out, this change should simplify usage and allow SwiftUI better efficiency in updates. We encourage you to watch the WWDC session on Observation to learn more about the benefits of switching to Observation in your own code.

As part of this change, the implicit Combine publishers for $state and $feedback (and others) that were previously automatically created by conforming to ObservableObject also went away when we dropped this conformance. To replace this functionality, we introduced the new AsyncSequence based ObjectCaptureSession.Updates<T> properties to support apps that want to handle programmatic state updates, like our sample app. Async update loop code can be placed programmatically in Tasks within your app, or attached to .task() view modifiers right in your SwiftUI code to tie their lifecycle to a particular View.

By when we can expect the new updates code from apple for Gide Capture source code in apple link ? Is anyone has fixed this ? Can anyone provide the source code which is running fine on 17.4.1 it would be more appreciate.

I fixed the old sample to work with the current session state instead of session.isAutoCaptureEnabled toggle

Fixed Sample

Hope that may help somebody.

Guided Capture sample - broken with iOS17 beta 4
 
 
Q