- Home /
Infinite video loop without crashing?
I know, Unity3d isn't mean't to be a video player. However, that's essentially what I'm using it for in my current project. I'm using a render texture to apply video to a complex 3d surface with a projector. After I have the meshes lined up with the physical space I just hit play and let it loop one or more videos for as long as the event its intended for lasts.
The problem is, Unity will inevitably freeze and I end up force quitting it. The length of the video doesn't make any difference. Sooner or later, usually within the first half hour of looping, it freezes. V-sync settings, fixing the frame rate, and breaking videos into smaller chunks all seem to have no effect. I'm deploying it as a PC standalone.
Its very niche, but any ideas on how to maintain a stable video loop for hours at a time would be greatly appreciated.
Well, the main issue for an application freezing typically lends itself to a memory leak, or improper memory management to begin with. Dealing with infinite loops specifically, your logic has to be sound and leak proof in order to maintain sustainability.
In your case of after half an hour, it sounds like there are potentially very small allocations that are adding up over time in the heap. Now, there of course is the off chance that Unity itself has a leak when dealing with looping videos like this because it's design was not really intended to do so, but in any case, sample code would be the only way we could try and help you.
In the loop he has to do some sort of heap management. I wish I had some psuedo code around but I haven't had to deal with large scale heap changes in a long time.
If you can reproduce this on a simple project with nothing extra added but a video playing and it crashes, please consider submitting a bug report.