iosswiftarkitworld-map

Swift -How much Data does an ARKit WorldMap take up


You can save a world map for later retrieval. I want to save several world maps but I cannot find anything on how much data each one takes up.

How much does data does each one take up and what determines the size of the data? For eg if I'm in my kitchen that's one thing but if I'm at the beach that's another and if I'm at the mall that's another. I'm not sure if they would be considered the size of a small compressed photo or large uncompressed video.

// Because ARWorldMap conforms to NSSecureCoding, you serialize it using NSKeyedArchiver:

func writeWorldMap(_ worldMap: ARWorldMap, to url: URL) throws {
    let data = try NSKeyedArchiver.archivedData(withRootObject: worldMap, requiringSecureCoding: true)
    try data.write(to: url)
}

// To restore the world map the next time your app launches, use NSKeyedUnarchiver:

func loadWorldMap(from url: URL) throws -> ARWorldMap {
    let mapData = try Data(contentsOf: url)
    guard let worldMap = try NSKeyedUnarchiver.unarchivedObject(ofClass: ARWorldMap.self, from: mapData)
        else { throw ARError(.invalidWorldMap) }
    return worldMap
}

Solution

  • Seems to be around 50mb

    I connected 2 worlds following this youtube tutorial. The project uses RealityKit and ARKit.

    On an iPhone 7+, before adding a WorldMap from another device, the Memory hovered around 280mb. After adding the WorldMap from an iPhone 11, the Memory on the 7+ kept jumping between 320mb-330mb (always closer to 330).

    On an iPhone 11, before adding a WorldMap from another device, the Memory hovered around 340mb. After adding the WorldMap from an iPhone 7+, the Memory on the 11 kept jumping between 380mb-390mb (always closer to 390).

    On both phones, using the numbers above, it occasionally lowered 10-20mb points but also raised 1-5 mb higher. But basically 50mb was the most common number.

    FYI I connected both phones to Xcode separately. I was unable to connect both at the same time.