Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Video player memory issues - can I get some info about memory management?

Discussion in '5.6 Beta' started by StarManta, Feb 6, 2017.

  1. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Only posting here because there is no information on the GDoc about this.

    What are best practices with regard to memory management and the video player? How does it load videos into memory, and how does this differ between video types and between platforms?

    Case in point: I have a simple video player test app with a video file in the project, linked using a member variable. Using the "Adam" video (36 MB mp4 file), the app functions as expected. Using our own test content, which works in the editor (a 237 MB h.264 m4v file), the app crashes on device due to a memory error.

    In our case, I would like to know if using another technique to load the video (e.g. putting the video in the streaming folder and loading it via URL, maybe?) would cause the same memory problem. I can investigate this by trial and error on my own (and I intend to as I wait for a response), but this is the sort of information that absolutely needs to be in the documentation, and it'd be nice not to have to spin my wheels figuring it out.

    And of course, if it's supposed to safely stream the video from disk and not load it into memory in full at all, then I've most certainly encountered a beta bug. But I have no idea if this is the expected behavior because, again, not in the documentation.

    It'd also be nice if the VideoPlayer class itself could be aware that the video is going to cause a memory issue and report it as such (or not load the video) rather than just waiting for the OS to crash the app.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Update: Putting the video into StreamingAssets did solve the memory issue, for anyone looking into this in the future.
     
  3. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi StarManta!

    Can you tell us what platform you are using? We did indeed fix file-loading on OSX/iOS so it avoids loading the file into memory and now reads from disk. This fix will appear in beta 10, and the workaround you found does indeed make sense for the time being. But when the fix is in you son't need to use the StreamingAssets anymore.

    We may eventually also add a control that lets you choose if the video is entirely loaded into memory or if it is streamed from disk, but not in 5.6. In 5.6 all implementations will stream from disk.

    Dominique
    A/V developer at Unity