They are saved as CIImage objects backed by the pixel buffers. However, these pixel buffers are the original ARKit buffers, and are thus owned by ARKit. They may be recycled at any time.
In the current setup, this may not pose a major issue as the ARSession is paused whenever the capture button is clicked, thus the pixel buffers have a lower possibility of being recycled.
But in the future, when this pause becomes optional (e.g. to enable Dead Reckoning), these buffers cannot be relied upon.
The following are some of the ways this issue can be prevented:
- Manually copy all the buffers into new pixel buffers and wrap that with a new CIImage.
- Create a CGImage from the CIImage which would result in the new CIImage being backed by a CGImage not touched by anyone else. Easier to implement, and historically, has been safer. But this will be inefficient compared to other solutions.