I followed the instruction in this session and tried to write a demo with Object Capture API. But there's a MTLDebugRenderCommandEncoder assertion fails every time I call session.startDetecting(), just after the bounding box shows up.
The error shows:
-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:5780: failed assertion `Draw Errors Validation
Fragment Function(fsRealityPbr): the offset into the buffer clippingConstants that is bound at buffer index 8 must be a multiple of 256 but was set to 128.
and my code is pretty simple:
var body: some View {
ZStack {
ObjectCaptureView(session: session)
if case .initializing = session.state {
Button {
session.start(imagesDirectory: getDocumentsDir().appendingPathComponent("Images/"), configuration: configuration) // 💥
} label: {
Text("Prepare")
}
} else if case .ready = session.state {
Button {
session.startDetecting()
} label: {
Text("Continue")
}
} else if case .detecting = session.state {
Button {
session.startCapturing()
} label: {
Text("Start Capture")
}
}
}
}
I'm wondering if anyone else is facing the same problem or if there's an error on my side?
UPDATE - Workaround
You can actually disable Metal API Validation in your build scheme to temporally bypass the internal assertion for debugging other codes, and wait until Apple release their fixes.
There's still some other internal crashes and assertion cannot be bypassed with this workaround, but these don't happens every time. Finally I was able to get an USDZ model.