Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Damaged textures on ios 14 and A12 or above after Texture2d.Apply

Discussion in 'Editor & General Support' started by SPL_X1, Sep 30, 2020.

  1. SPL_X1

    SPL_X1

    Joined:
    Dec 23, 2015
    Posts:
    19
    Hello, we encountered a problem on ios devices with iOS 14.0 and Apple A12 or above.
    We load several thousand textures from memory as follows:
    1. Use the function Texture2d.LoadImage (textureBytes, markNonReadable: false);
    2. Using Texture2d.GetRawTextureData we read texture data
    3. Texture2d.Apply (false, makeNoLongerReadable: true) - free the ram copy of the texture
    As a result, some textures are damaged. If we comment Texture2d.Apply (false, makeNoLongerReadable: true) call, the problem goes away.

    unity 2019.3.11f1
     
  2. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,053
    Not an expert but calling Apply to unload a texture from memory doesn't look right

    then you are asking unity to apply all changes to the texture and NOT update the mipmaps. (the false in the argument)

    having the texture looking differently than the mipmaps may be the issue
     
  3. SPL_X1

    SPL_X1

    Joined:
    Dec 23, 2015
    Posts:
    19
    We don't need mipmaps, we are creating Texture2D without mipmaps:
    var texture = new Texture2D(width, height, TextureFormat.ARGB32, mipChain: false, true)
     
  4. SPL_X1

    SPL_X1

    Joined:
    Dec 23, 2015
    Posts:
    19
    Resolved this with Texture2d.Apply(false, makeNoLongerReadable: true) call when we have loaded all textures.