Android crash on WebCamTexture.Play()

Unity 5.5.0p1

Whenever I close the app manually, make the app crash or pause the app this crashes at the next attempt to play a WebCamTexture.

For it to work again I must restart the phone.

Simple way to do this:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class WebCamScript : MonoBehaviour
{
    private WebCamTexture mCamera, mCamera2;
    public GameObject frontCameraPlane,
        backCameraPlane;

    private bool frontCamera = true;
    private WebCamDevice[] devices;

    IEnumerator Start()
    {
        devices = WebCamTexture.devices;

        mCamera2 = new WebCamTexture(Screen.width, Screen.height);
        mCamera2.filterMode = FilterMode.Trilinear;

        backCameraPlane.GetComponent<Renderer>().material.mainTexture = mCamera2;

        float yScale2 = backCameraPlane.transform.localScale.x * (float)Mathf.Min((float)Screen.width, (float)Screen.height) / (float)Mathf.Max((float)Screen.width, (float)Screen.height);
        backCameraPlane.transform.localScale = new Vector3(backCameraPlane.transform.localScale.x, yScale2, 1);

        if (devices.Length > 1)
        {
            mCamera = new WebCamTexture(devices[devices.Length - 1].name, Screen.width, Screen.height);
            mCamera.filterMode = FilterMode.Trilinear;

            frontCameraPlane.GetComponent<Renderer>().material.mainTexture = mCamera;

            float yScale1 = -frontCameraPlane.transform.localScale.x * (float)Mathf.Min((float)Screen.width, (float)Screen.height) / (float)Mathf.Max((float)Screen.width, (float)Screen.height);
            frontCameraPlane.transform.localScale = new Vector3(frontCameraPlane.transform.localScale.x, yScale1, 1);
        }

        yield return 0;

        if (devices.Length > 1)
        {
            frontCameraPlane.SetActive(true);
            backCameraPlane.SetActive(false);
            mCamera.Play();

        }
        else
        {
            frontCamera = false;
            frontCameraPlane.SetActive(false);
            backCameraPlane.SetActive(true);
            mCamera2.Play();
        }
    }
}

This is just the initialization of my script, if you place 2 game objects on screen with he height 100% on portrait mode it will make them fill all the screen.

if you have 2 cameras it will start with front camera, else it will show back/only camera.

--------------------How to make it crash-------------------------

Just hit the home button and then try to resume the app.
It will crash when the WebCamTexture.Play(); is called.

Problem isn’t just that, problem is that you won’t be able to close the app and make it work again unless you restart the phone.

5.5.1 release notes

  • Android: Fixed a crash when reloading or resuming scene which uses WebCamTexture. (855603, 859268)

I’ll test it tomorrow and hope it is fixed

This problem still exists in the latest version (5.5.2p3). If you call WebCamTexture.Pause() and then call WebCamTexture.Stop() in OnApplicationPause() then there may be less crashes but still could not resolve the problem
completely.
.