I used to be able to encode CapturedRoomData to Data using JSONEncoder with the following code:
// Encode CapturedRoomData
func encodeCapturedRoomData(_ roomData: CapturedRoomData) -> Data? {
print("#ECRD1 - Data: \(roomData)")
do {
let encodedRoom = try JSONEncoder().encode(roomData) // as Data
print("#ECRD2 - Encoded: \(encodedRoom.description)")
return encodedRoom
} catch {
print("#ECRD3 - Failed with error: \(error)")
}
return nil
}
but a few weeks ago I noticed this approach is no longer working. The encoding fails and I get the following error:
#ECRD3 - Failed with error: invalidValue(RoomPlan.CapturedRoomData, Swift.EncodingError.Context(codingPath: [], debugDescription: "Invalid data", underlyingError: nil))
The roomData passed into the function in this example is the CapturedRoomData received from the ’didEndWith’ delegate method, running on a device with iOS 17.3.1.
Edit: Updating to the latest iPadOS (17.4.1) and Xcode (15.3) versions did not solve the problem
Can anyone help me find the root cause of this?
For reference, here’s what the CapturedRoomData looks like (with the keyframes omitted):
#ECRD1 - Data: CapturedRoomData(keyframes: [...], coreAsset: <RSAsset: 0x283988bd0>, arFrameReferenceOriginTransform: simd_float4x4([[0.9995456, 0.0, 0.030147359, 0.0], [0.0, 1.0, 0.0, 0.0], [-0.030147359, 0.0, 0.9995456, 0.0], [0.38664898, 0.93699455, 0.38685757, 1.0]]))