I’m developing an app where the user can switch between a 3D mode and an AR mode. Starting out in 3D mode by default I can activate AR mode without a problem. However switching back and forth I get numerous exceptions/errors when restarting AR mode.
This is thrown once:
InvalidOperationException: Cannot set camera configuration because you have not disposed of all XRCpuImage and allowed all asynchronous conversion jobs to complete
Niantic.Lightship.AR.Loader.LightshipARCoreLoader.UpgradeCameraConfigurationIfNeeded () (at <00000000000000000000000000000000>:0)
Niantic.Lightship.AR.Utilities.MonoBehaviourEventDispatcher+PrioritizingEvent.InvokeListeners () (at <00000000000000000000000000000000>:0)
These are thrown repeatedly afterwards four several seconds at least:
[Error] [2025-07-03 10:10:33.597] [537231580336] Failed to upgrade the camera configuration to the required minimum resolution. We only expect this to happen when the ARSession was reset when not all camera images were disposed. Check the exception from ARCoreCameraSubsystem to verify that is the case,and if so, make sure to dispose all camera XRCpuImages before resetting the ARSession.
Niantic.Lightship.AR.Utilities.Logging.NativeApi:Lightship_ARDK_Unity_Log(LogLevel, String, String, Int32, String)
Niantic.Lightship.AR.Loader.LightshipARCoreLoader:UpgradeCameraConfigurationIfNeeded()
Niantic.Lightship.AR.Utilities.PrioritizingEvent:InvokeListeners()
The mode switch is done by disabling the parent AR GameObject and enabling the parent 3D GO essentially. The ARSession instance is Reset() on restart which seems to trigger the error.
I found the messages source in LightshipARCoreLoader.cs:189 and the supposed functionality to cover the case in SubsystemDataAcquire.cs:143.
I’m not using any XRCpuImage instances myself. In the meantime I even disabled the occlusion manager, semantics manager and mesh managers to no avail. It seems that as soon as Lightship manages AR, this problem occurs.
I did try calling ARSession.Reset() in a Coroutine after disabling the corresponding component and waiting a frame but it didn’t change the fact.
Thanks for reaching out. It’s interesting that it’s only happening on Android. Let me check in with out some of our ARDK team to see if this is potentially an issue with the ARCore implementation
Apologies for the silence on my end. We’re still looking into this. I did want to ask what other AR features/ components you’re using on your project. From the features you’ve already listed, we use Unity’s Occlusion but we do have the Lightship Occlusion extension. Similarly with Meshing, we use a mix of Unity’s meshing with our extensions. Would you happen to be using any of our extensions for these components?
The AR Session itself is managed by Unity’s ARFoundation, not Lightship. By any chance have you tried the same thing on a project that’s only running AR Foundation without Lightship or any of our extensions?
The main reason I’m asking is that despite the errors being thrown having the Lightship namespace on them, the components in question appear to be from ARCore and I’m seeing AR Foundation functions being thrown in there as well so I wanted to see if you can rule out the issue happening on AR Foundation.
The project was initially created without any Lightship components just using what Unity, Apple and Google provided. I recently added Lightship to add occlusion culling, semantics and the platform independent meshing capabilities.
The described problems arose afterwards.
What makes it interesting is the error message about usage of XRCpuImage. The app never did and I can only imagine occlusion or semantics do.
Switching between an AR context and a non-AR 3D context is a core functionality unfortunately.
So what I was able to uncover is that it appears that with ARCore the XRCpuImage isn’t always disposed of properly. Can you try inserting the code I’ll provide below just before you disable the AR session to see if getting rid of any XRCpuImage that it’s holding onto fixes the issue?
if (cameraManager.TryAcquireLatestCpuImage(out XRCpuImage image)){ image.Dispose();}
Also, I’m going to report these errors so our team is aware that the XRCpuImage isn’t always disposed of with ARCore. I see you’re on Unity 6000.0.46 may I also know the current version of ARFoundation that your project is using?
I tested this but to no avail. It seems there is no CPUImage as the method call comes up empty.
The AR Foundation plugin is at 6.1.1, XR Core utilities@2.5.2, Google ARCore@6.0.6 and Apple ARKit@6.1.1. All at their latest available as of now.
If you don’t have any strong dependencies with AR Foundation 6 can you try downgrading the package to 5.2.0? We’ve noticed that when installing the latest version of ARDK, ARF 6 installs itself which isn’t a version we’ve yet to fully test and validate and it could be the source of the issue. 5.2.0 is supported.
Please let me know if this is still happening after downgrading AR Foundation or if you’re getting any new/ different logcat error outputs
We don’t rely on anything v6 specific but downgrading these packages, which include ARCore and ARKit in this case, while staying on Unity 6000.0 seems wrong. Doing it anyway results in the following errors which happen to be in UNITY_6000_0_OR_NEWER ifdefs:
Library\PackageCache\com.nianticlabs.lightship@3d330ee6180a\Runtime\Subsystems\Playback\LightshipPlaybackCameraSubsystem.cs(432,29): error CS0246: The type or namespace name ‘ShaderKeywords’ could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.nianticlabs.lightship@3d330ee6180a\Runtime\Subsystems\Playback\LightshipPlaybackCameraSubsystem.cs(432,44): error CS0115: ‘LightshipPlaybackCameraSubsystem.LightshipPlaybackProvider.GetShaderKeywords()’: no suitable method found to override
Library\PackageCache\com.nianticlabs.lightship@3d330ee6180a\Runtime\Subsystems\Occlusion\LightshipOcclusionSubsystem.cs(865,29): error CS0246: The type or namespace name ‘ShaderKeywords’ could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.nianticlabs.lightship@3d330ee6180a\Runtime\Subsystems\Occlusion\LightshipOcclusionSubsystem.cs(865,44): error CS0115: ‘LightshipOcclusionSubsystem.LightshipOcclusionProvider.GetShaderKeywords()’: no suitable method found to override
Library\PackageCache\com.nianticlabs.lightship@3d330ee6180a\Runtime\Subsystems\Playback\LightshipPlaybackOcclusionSubsystem.cs(588,29): error CS0246: The type or namespace name ‘ShaderKeywords’ could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.nianticlabs.lightship@3d330ee6180a\Runtime\Subsystems\Playback\LightshipPlaybackOcclusionSubsystem.cs(588,44): error CS0115: ‘LightshipPlaybackOcclusionSubsystem.LightshipPlaybackProvider.GetShaderKeywords()’: no suitable method found to override
Thanks for your patience. Yeah so it looks like Unity changed something with SharedKeywords in Untiy6/AR Foundation 6 which caused the breakage when you downgraded.
We just recently ran and verified that our samples are working with version 6.0.3 of AR Foundation if you can install that version instead. Sorry for the back and forth with all the version installs
6.0.3 doesn’t seem to affect my problem with calling ArSession.reset(). It still throws errors about the CPUImages even after a clean build.
I think I’m going to have to remove the reset call and see where that leads.
Got it. On our end we can continue to do some testing if you’re able to send over a simplified version of your project for us to build. I know this is a public forum so if you want to send me the link privately you can do that as well.
I don’t think I saw your project come in yet. Just wanted to let you know that it would actually be better if you could reach out to us via support@nianticspatial.com rather than sending your project as a DM.