androidunity-game-enginevideorenderoculusgo

multiple videos on OculusGo, Android - app is crashing


[EDITED] I'm preparing an application for OculusGo = Android In the scene there's 4 characters represented by video clips. Video size between 10mb - 30 mb each.

All video are with the shader GoogleVR/Unlit/TransparentOverlay The videos were encoded to WebM/ VP9/ keep alpha with Adobe encoder. The videos further transcoded in unity to Android, VP8 (again).

The videos loaded from a resources folder at the begining of the scene, and then when it's time to play them VideoPlayer.Play() is called from each one of them and finally they all play together. (Start one after another and continue together).

The issue is: My app is crashing when the third video is supposed to play. It doesn't crash when I "prepare" the video, but only on "VideoPlayer.Play()"

Here's my current code:

public float waiting;
public AudioSource characterAudio;

VideoPlayer videoPlayer;
bool videoStarted = true;

void Awake () {
    
    videoPlayer = GetComponent<VideoPlayer>();
}

private void Update()
{
    if (characterAudio != null)
    {
        if (characterAudio.isPlaying && videoStarted)
        {
            StartCoroutine(StartVideo());
            videoStarted = false; 
            Debug.Log(characterAudio.name + " called once from update");
        }
    }
}

IEnumerator StartVideo()
{
    yield return new WaitForSeconds(waiting);
    videoPlayer.enabled = true;
    videoPlayer.Prepare();
    while(!videoPlayer.isPrepared)
    {
        Debug.Log("video is preparing");
        yield return null;
    }

    videoPlayer.Play();
    Debug.Log("videoStarted, char name is: " + characterAudio.name);
}

This is the errors I get from logcat (using command: logcat |grep -i unity)

ActivityManager: Force removing ActivityRecord

Consumer closed input channel or an error occurred. events=0x9

Channel is unrecoverably broken and will be disposed!

InputDispatcher: Attempted to unregister already unregistered input channel

Please help, I've been trying for two weeks to get these videos to run simultaneously.

Also I read about using different thread here: https://gamedev.stackexchange.com/questions/113096/how-to-not-freeze-the-main-thread-in-unity and about videos playing simultaneously here: Unity App freezes when loading Multiple Videos on same Scene

I ran logcat (not unity one), and this is what I got right after video preparation has ended:

Screenshot from terminal


Solution

  • The way I solved this issue is with the following steps:

    1. instead of having 4 different videos to play simultaneously and using memory of four videos, I used one video - devided by 4 - each character got a "slot" on the one video that would run.
    2. I used one material - instead of using 4 materials, one material to play the video. This material display a video of all 4 characters, so to display the character correctly, I offset the material render texture x,y position and offset, so only one character is displayed in four different places in the scene.

    So to summaries instead of loading and playing 4 videos with four different materials and creating overload on the system, I played 1 video on 1 material. Application run smoothly.