Viro: GPU Memory Leak on Android

Created on 13 Nov 2018  路  12Comments  路  Source: viromedia/viro

Environment

  1. Development OS: Mac.
  2. Device OS & Version: Tested on Android 8.0.
  3. Version: ViroReact 2.11.0; React Native 0.57.4.
  4. Device(s): Moto G6.

Description

When loading and unloading several Viro3DObjects, eventually the objects stop loading and one sees the following error:

11-07 15:46:25.440 14979 16928 E Adreno-GSL: <gsl_memory_alloc_pure:2203>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
11-07 15:46:27.849 14979 16928 W Adreno-GSL: <sharedmem_gpuobj_alloc:2337>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory

All 12 comments

@radvani mentioned in slack that this is on the team's radar. Just wanted to issue-ify for posterity.

HI @slycoder, thanks for the report. We've resolved this issue and the fix will be available in our new release coming this week.

Hi @slycoder ,
We just released ViroReact version 2.12.0, that resolves this issue. Check it at -> https://docs.viromedia.com/docs/releases. Closing this issue. Let us know if you still see the same.

Hi @manbod,

I'm still seeing this on the latest releases (both 2.12 and 2.13) on the same device. Here's an example of an error message (it repeats quite frequently).

01-11 16:57:04.612  3349  4084 E Adreno-GSL: <gsl_memory_alloc_pure:2203>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
01-11 16:57:04.990  3349  4084 W Adreno-GSL: <sharedmem_gpuobj_alloc:2337>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory

Note that onError is never called (I'm not sure if that's a separate known problem). FWIW, the model seems to be loading correctly, as I see the Loading FBX from file... and Downloaded URL... log lines. Here is the debug info about the device

01-11 16:55:52.649  3349  4084 I Viro    : Acquired sRGB framebuffer
01-11 16:55:52.654  3349  4084 I Viro    : GPU vendor [Qualcomm], renderer [Adreno (TM) 506]
01-11 16:55:52.655  3349  4084 I Viro    : Creating render targets with configuration:
01-11 16:55:52.655  3349  4084 I Viro    : [MRT supported:   1]
01-11 16:55:52.655  3349  4084 I Viro    : [Shadows enabled: 1]
01-11 16:55:52.655  3349  4084 I Viro    : [HDR supported:   1, HDR enabled:   0]
01-11 16:55:52.655  3349  4084 I Viro    : [PBR supported:   1, PBR enabled:   0]
01-11 16:55:52.655  3349  4084 I Viro    : [Bloom supported: 1, Bloom enabled: 0]

Finally, note that this only occurs when unmounting a scene and then mounting a new scene; the first scene loads and animates correctly but the second one will OOM. A suspicious line in the logs may point to the issue:

01-11 16:55:44.541  3349  3349 I Viro    : Failed delete render target: driver was released

Hi @slycoder ,
Thanks for checking on this and reporting. Any chance you could share source for your scene (or equivalent other scene) with us so we can reproduce this exact leak on our end? We'd like to resolve this for an upcoming release.

Thanks

Hi, sorry for the delay as we were trying to narrow down the source of the leak. It seems to be due to having a large shadow map (we had it set to 2048).

Here is a sketch of something that will cause the leak:

  <ViroScene>
      <ViroDirectionalLight
        direction={[-0.35, -1, -0.35]}
        color="white"
        intensity={600}
        castsShadow
        shadowMapSize={2048}
        shadowNearZ={1}
        shadowFarZ={200}
        shadowOpacity={1.0}
        shadowOrthographicPosition={[35, 100, 35]}
        shadowOrthographicSize={100}
      />
      <ViroCamera
        position={[0, 0, 0]}
        rotation={[0, 0, 0]}
        fieldOfView={60}
        active
      />
      <Viro3DObject
        ignoreEventHandling
        scale={[1, 1, 1]}
        position={[0, 0, 0]}
        rotation={[0, 0, 0]}
        source={uriToVRXFile}
        type="VRX"
      />
  <ViroScene>

Note that you must unmount and remount the enclosing Viro3DSceneNavigator to cause the leak to show up (and also note that it only happens on the aforementioned GPU). Depending on the device and the 3d object, you may need to mount and unmount several times.

Thanks for the additional information and clear repro steps. We will take a look. Based on your comment, sounds like a smaller shadow map, does not result in a leak?

It seems that way (or at the very least the leak is so unegregious that one would have to mount/umount a whole lot of times before the gpu fills up).

It occurs to me there could be a tiny leak somewhere else and using a large shadow map pushes things so close to the limit that the tiny leak which would normally not be noticeable becomes noticeable.

is it fixed?

I'm seeing something similar when unmounting an old and mounting a new ViroVRSceneNavigator on iOS

"Failed delete render target: driver was released"

I'm seeing, on iOS:

"Failed delete render target: driver was released"

After navigating away from a ViroARSceneNavigator. Not currently a major issue, but I am looking to see if it could be causing any crashes after cumulative use.

Was this page helpful?
0 / 5 - 0 ratings