Closing scene with active webcamTexture crashes on Android [SOLVED]

Closing scene with active (Playing or Paused) webcamTexture crashes on Android, with Error Fatal signal 11 (SIGSEGV)

Tested on Samsung Galaxy 3
Android version: 4.4.2
Unity 5.2.2.

To ‘fix’ the problem I first call Stop(); then Destroy (with breaks in between). I spent a few hours on this to figure it out. This is my script, hopefully it helps someone.

private IEnumerator ExitScene()
    {
        if(webcamTex != null)
            webcamTexLink.Stop();

        yield return new WaitForSeconds(0.2f);
       
        if(webcamTex != null)
            Destroy(webcamTex);
       
        yield return new WaitForSeconds(0.2f);

       Application.LoadLevel("some_place_else");
    }
4 Likes

Thanks for the solution. My day was saved!

For me WebCamTexture was crashing whenever i call the function ‘Stop()’. It was really frustrating. I didn’t really found a solution but i’ve found that this issue/bug is resolved in Unity 2017.1.0f3. It doesn’t crash at all in that version, so i’d recommend moving to 2017.

Hope this helps someone out there! Cheers!

This very same bug (or very similar) is back in 2018.2.0f2

Luckily the workaround seems to work here as well; no need to actively destroy the webcamTexture, just waiting a fraction of a second seems to be enough.

Reported as bug:

  1. What happened

A webcam picture is displayed on a rawImage texture.

The managing script stops the webcam picture in both an OnDisable and OnDestroy handler

When switching to another scene using the SceneManager the app crashes on Andoid

This can be prevented by waiting a short time between stopping the Webcam playback and swicthing to the new scene.

Both iOS and the editor (osx) are not affected.

Tested and verified on the following platforms:

Nokia 6.1 - Android 8.1

LGE LG G6 (lucye) - Android 7.0

Google Pixel (sailfish) - Android 7.1

Huawei Mate 9 (HWMHA) - Android 7.0

Samsung Galaxy J7 (2016) (j7xelte) - Android 6.0

Samsing Galaxy S7 Edge (hero2lte) - Android 6.0

Google Pixel (sailfish) - Android 8.0

Google Pixel 2 (walleye) - —

Samsung Galaxy J1 Ace (j1acevelte) - Android 5.1