Samsung / GearVRf

The GearVR framework(GearVRf) is an Open Source VR rendering library for application development on VR-supported Android devices.
http://www.gearvrf.org
Apache License 2.0
407 stars 217 forks source link

Solve memory problems #747

Closed arianaa30 closed 8 years ago

arianaa30 commented 8 years ago

I have an interesting question. I have 4 high resolution video objects (2K) in front, back, right, and left, and currently I can not add all of them into the scene and play, probably due to memory problems on my Galaxy S7. So what I want to do is to play one of them which is visible, and disable the ones which are not visible (setEnable(false)). But this doesn't solve the memory problem. I tried removing the videoObject from the scene, that also didn't work. Any ideas how to solve this? Maybe there is some ways for clearing memory within GearVR?

liaxim commented 8 years ago

It is possible we are not freeing the memory. We will investigate. With just one videoObject it works for you? Could you share logcat output with us?

arianaa30 commented 8 years ago

Yes, here is only the errors output for my app:

07-25 15:02:24.367: E/MediaPlayer(25117): error (1, -19)
07-25 15:02:24.377: E/MediaPlayer(25117): Error (1,-19)
07-25 15:02:24.467: E/MediaPlayer(25117): error (1, -19)
07-25 15:02:24.467: E/MediaPlayer(25117): Error (1,-19)

And the verbose one is too long. It is attached.

verbose.txt

arianaa30 commented 8 years ago

And, yes. With only one and two it works. Apparently Galaxy S7 can not handle more than 2x (1920*3820) (total of 8K) video resolutions!!

liaxim commented 8 years ago

I don't see a leak in the framework when it comes to adding and removing video scene objects.

But once you remove a video scene object it is not immediately garbage-collected. It may take a while or maybe never if there is no memory pressure. The MediaPlayer though expects you to call the release method once you think you are done with it. So you might want to call GVRVideoSceneObject.release right after removing the video scene object from the scene graph.

arianaa30 commented 8 years ago

Ok. I'll see if that works. So what does video[0].setEnable(false); really do? It doesn't release any resources? Well, in my application I might at any moment show the video again from that specific point in time. So if I release it, it means I have to create it again, add it to the scene, and start again?! Any better options to avoid memory problem but at the same time minimize the video play delays?

liaxim commented 8 years ago

setEnable(false) keeps the object alive and in the scene graph but it is not displayed any more.

As for the options - I don't have anything but making sure you are releasing the media player instances as soon as you are done with them.

arianaa30 commented 8 years ago

OK. I'll try that out...Thanks.

liaxim commented 8 years ago

@arianaa30 Are you still having problems?

arianaa30 commented 8 years ago

No, thanks. I don't want to lose the time of mediaplayer, so I can't really release it. I wish there were some mechanisms inside the setEnabled that could do some sort of resource releasing automatically!

liaxim commented 8 years ago

I think the resources are being held by all the MediaPlayer instances that you need to keep active. There is nothing GVRF can do to help with that..

liaxim commented 8 years ago

If you think we should do something, let us know. Otherwise, can we close this issue?

arianaa30 commented 8 years ago

Yes, please close it.