Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Oculus Quest 2 hangs and crashes the app while Loading 8000*8000 images

Discussion in 'VR' started by hcpinteractive, Aug 14, 2023.

  1. hcpinteractive

    hcpinteractive

    Joined:
    May 20, 2019
    Posts:
    9
    This is the Code Which gets the Images from the Folder and then add to an Texture2D List named render .
    While Loading the Images the app crashes and stops responding.
    This code works Perfectly in Unity Editor/Desktop but the app is crashes in the VR App in Oculus Quest 2

    Code (CSharp):
    1. var dir = new DirectoryInfo(Path.Combine(Application.persistentDataPath, "Projects", "TEST", "Images"));
    2.         var files = dir.GetFiles();
    3.         for (int i = 0; i < files.Length; i++)
    4.         {
    5.             byte[] bytes = File.ReadAllBytes(files[i].ToString());
    6.             Texture2D loadTexture = new Texture2D(1, 1); //mock size 1x1
    7.             loadTexture.LoadImage(bytes);
    8.             renders.Add(loadTexture);
    9.         }
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,271
    how many images you have there?

    maybe runs out of memory or fails to load from that path,
    whats the error in device log/logcat?
     
  3. hcpinteractive

    hcpinteractive

    Joined:
    May 20, 2019
    Posts:
    9
    5 Images are There in the Path
     
  4. hcpinteractive

    hcpinteractive

    Joined:
    May 20, 2019
    Posts:
    9
    Logcat error is Memory exception failure
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,271
    test with smaller or fewer images to confirm,
    its mobile device so probably cannot handle those..
     
  6. hcpinteractive

    hcpinteractive

    Joined:
    May 20, 2019
    Posts:
    9
    It works with smaller images.
    Its look like memory issue. but can not find workaround to fix this. I can not reduce image size(8192x8192) as I required it to show good quality images in VR.
    I am trying to use Streaming asset but as my images are getting loaded from server then how can I replace that in apk's streaming asset folder.
    For asset bundle I read that we can not generate asset bundle in runtime. As I have another app to upload images to server.
     
  7. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,271
  8. hcpinteractive

    hcpinteractive

    Joined:
    May 20, 2019
    Posts:
    9
    Here's an app flow:
    1) Having one admin app (Desktop) to upload images to the server folder wise.
    2) Having another app (quest 2) to view 360 images from server using a texture mapped on sphere. I need to iterate through images using thumbstick one by one. This functionality works smooth if I build with 8k images pre loaded in build. But starts crashing when I try to load dynamically.

    I think sparseTexture would work if there is a problem in pre loaded version too, but it works fine.
    amlify-texture seems dead.

    This looks crazy as I am using www.dispose() too to clear memory after every image load..!
     
  9. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,271