Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak using GVRViewSceneObject #2037

Open
felislynx-silae opened this issue Mar 27, 2019 · 4 comments
Open

Memory leak using GVRViewSceneObject #2037

felislynx-silae opened this issue Mar 27, 2019 · 4 comments

Comments

@felislynx-silae
Copy link

felislynx-silae commented Mar 27, 2019

Hi, using latest version of framework, using Android views will cause this exception:

2019-03-27 15:56:26.271 2902-2902/pl.fream.evryplacevr.gearvr.debug E/GraphicBufferAllocator: Failed to allocate (644 x 236) layerCount 1 format 1 usage 133: 5
2019-03-27 15:56:26.271 2902-2902/pl.fream.evryplacevr.gearvr.debug E/BufferQueueProducer: [SurfaceTexture-431-2902-365] dequeueBuffer: createGraphicBuffer failed
2019-03-27 15:56:26.271 2902-2902/pl.fream.evryplacevr.gearvr.debug E/Surface: dequeueBuffer failed (Out of memory)
2019-03-27 15:56:26.283 2902-2902/pl.fream.evryplacevr.gearvr.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: pl.fream.evryplacevr.gearvr.debug, PID: 2902
    android.view.Surface$OutOfResourcesException
        at android.view.Surface.nativeLockCanvas(Native Method)
        at android.view.Surface.lockCanvas(Surface.java:330)
        at org.gearvrf.scene_objects.GVRViewSceneObject$RootViewGroup.dispatchDraw(GVRViewSceneObject.java:600)
        at android.view.View.updateDisplayListIfDirty(View.java:19288)
        at android.view.View.draw(View.java:20075)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
        at android.view.View.draw(View.java:20355)
        at com.android.internal.policy.DecorView.draw(DecorView.java:979)
        at android.view.View.updateDisplayListIfDirty(View.java:19297)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:800)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:3488)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3275)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2810)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1779)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7810)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
        at android.view.Choreographer.doFrame(Choreographer.java:658)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6938)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
2019-03-28 09:47:38.013 23752-24457/pl.fream.evryplacevr.gearvr.debug W/art: Large object allocation failed: ashmem_create_region failed for 'large object space allocation': Too many open files
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at android.graphics.SurfaceTexture.nativeUpdateTexImage(Native Method)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at android.graphics.SurfaceTexture.updateTexImage(SurfaceTexture.java:240)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.scene_objects.GVRViewSceneObject$RootViewGroup$5$1.run(GVRViewSceneObject.java:657)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.GVRViewManager.doMemoryManagementAndPerFrameCallbacks(GVRViewManager.java:270)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.GVRViewManager.access$700(GVRViewManager.java:47)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.GVRViewManager$3.beforeDrawEyes(GVRViewManager.java:455)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.GVRViewManager.beforeDrawEyes(GVRViewManager.java:514)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.OvrViewManager.beforeDrawEyes(OvrViewManager.java:163)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.OvrViewManager.drawEyes(Native Method)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.OvrViewManager.onDrawFrame(OvrViewManager.java:254)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at org.gearvrf.OvrVrapiActivityHandler$6.onDrawFrame(OvrVrapiActivityHandler.java:383)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1562)
2019-03-28 09:47:38.023 23752-23826/pl.fream.evryplacevr.gearvr.debug W/System.err:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1262)
2019-03-28 09:47:38.027 23752-23752/pl.fream.evryplacevr.gearvr.debug E/AndroidRuntime: FATAL EXCEPTION: main

Even though every time i'm removing all child objects from scene and removing everything from layouts, too many of them (views) stays in DecorView. They are visible in LayoutInspector. If you create 10 views, each with simple layout (LinearLayout + TextView) then remove, add again etc. after some time this crash happens. This wasn't happening on 3.2 and 3.3 framework version.

https://drive.google.com/open?id=1dh8o8_2w8yvDeDmyuOt063KLzcNMMkcM <-- layout inspector screenshot

@liaxim
Copy link
Contributor

liaxim commented Mar 28, 2019

The ViewSceneObject went through significant changes. It is not obvious how it takes care of cleanup and I guess it doesn't do it that well based on your report. Looking at it.

@liaxim
Copy link
Contributor

liaxim commented Mar 28, 2019

Actually I cannot reproduce with the latest master. Modified gvr-renderableview to remove and add new scene objects and views on tapping the screen. Diff attached: diff.txt

Examined the heap after dozens of iterations and it looks ok. The ViewSceneObject has a onRemoveParentObject that looks to be doing the right thing on removing a scene object from the scene graph. As long as the scene object has no more strong references everything gets cleaned up, eventually.

@liaxim
Copy link
Contributor

liaxim commented Mar 28, 2019

If you are ok with this, you could adb shell am dumpheap your app and send the dump to [email protected]. I can try to find out what keeps strong references in your case.

@felislynx-silae
Copy link
Author

Hi, tomorrow i'll do that. I'll try to do it just before crash happens. We made many changes today to achieve LayoutInspector to have only necessary views for specific scene (our internal one, not gvr). But still, GraphicBufferAllocator cannot allocate more memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants