Loading Textures and Meshes as Non-readable / GPU-only

Loading textures or meshes in a way that causes them to become non-readable at runtime causes exceptions to get thrown the next frame. This would in theory cause a balooning amount of ram usage, would it not?

Here are some examples:

UnityWebRequestTexture.GetTexture(fileUri, true);

and

texture.Apply(updateMipMaps, true);

both cause this error.

just as well

mesh.UploadMeshData(true);

causes a similar error.

Are these known issues? Are my assumptions about memory usage incorrect? It at least seems to cause the execution times of these methods to increase, but maybe that is some sort of post processing that is happening in the method that is no longer throwing?

Here is are some stack traces from the texture loading examples

ArgumentException: Texture2D.GetPixels32: texture data is either not readable, corrupted or does not exist. (Texture '')
  at Unity.PolySpatial.Internals.ConversionHelpers.ToPolySpatialFallbackTextureData (UnityEngine.Texture2D tex2d, System.Action`2[T1,T2] postConversionCallback) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.SendTextureAssetChanged (Unity.PolySpatial.Internals.PolySpatialAssetID assetID, UnityEngine.Object unityTexture, System.Boolean allowNativeTextures) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChanges () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () [0x00000] in <00000000000000000000000000000000>:0 
Unity.PolySpatial.Internals.PolySpatialCore:PolySpatialAfterLateUpdate()
ArgumentException: Texture2D.GetPixels32: texture data is either not readable, corrupted or does not exist. (Texture '')
  at Unity.PolySpatial.Internals.ConversionHelpers.ToPolySpatialFallbackTextureData (UnityEngine.Texture2D tex2d, System.Action`2[T1,T2] postConversionCallback) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.SendTextureAssetChanged (Unity.PolySpatial.Internals.PolySpatialAssetID assetID, UnityEngine.Object unityTexture, System.Boolean allowNativeTextures) [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChanges () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () [0x00000] in <00000000000000000000000000000000>:0 
  at Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

Would pasting the very similar mesh stack traces be useful as well?

PolySpatial needs to read the textures in order to then send the image data to RealityKit. The GPU versions of the textures are not used at all, so actually you can just not call Apply if you need to save memory.

1 Like

Cool, thank you!