Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

SetCameraEmitGeometryCallback Thread Crash when building project for iOS

Discussion in 'iOS and tvOS' started by narner, Jan 27, 2020.

  1. narner

    narner

    Joined:
    Jan 27, 2020
    Posts:
    1
    First off, disclosure --- I'm quite new to using Unity; come from an iOS/macOS development background.

    I have a Unity project with a video player that runs fine on a desktop environment, but when building/running for iOS, I'm getting this StackTrace:

    * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xc38)
    * frame #0: 0x000000010126252c ZoolikonDemo`::SetCameraEmitGeometryCallback() [inlined] IsRegistered at CallbackArray.h:223:32 [opt]
    frame #1: 0x000000010126252c ZoolikonDemo`::SetCameraEmitGeometryCallback() [inlined] IsRegistered at CallbackArray.h:154 [opt]
    frame #2: 0x000000010126252c ZoolikonDemo`::SetCameraEmitGeometryCallback() [inlined] IsRegistered<VideoPlayer> at CallbackArray.h:291 [opt]
    frame #3: 0x000000010126252c ZoolikonDemo`::SetCameraEmitGeometryCallback() at VideoPlayer.cpp:1963 [opt]
    frame #4: 0x0000000101262eb8 ZoolikonDemo`::UpdatePlaybackParams() at VideoPlayer.cpp:2038:5 [opt]
    frame #5: 0x00000001012649cc ZoolikonDemo`::AwakeFromLoad() at VideoPlayer.cpp:2027:9 [opt]



    This is the script I have for video playback; which is attached to the Main Camera of my Unity scene:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayVideoScript : MonoBehaviour
    6. {
    7.  
    8.     public UnityEngine.Video.VideoPlayer videoPlayer;
    9.  
    10.     bool isOpen = false;
    11.  
    12.     bool buttonPressed = false;
    13.  
    14.     void OnGUI() //I think this must be used on the camera so you may have to reference a gui controller on the camera
    15.     {
    16.         if(isOpen) //Is it Open?
    17.         {
    18.             if(GUI.Button(new Rect(Screen.width/2, Screen.height/2, 200, 200), "GREEN")) //Display and use the Yes button
    19.             {
    20.                 Debug.Log("Yes");
    21.                 videoPlayer.Play();
    22.                 isOpen = false;
    23.                 buttonPressed = true;
    24.             }
    25.             if(GUI.Button(new Rect(Screen.width/3, Screen.height/2, 200, 200), "RED")) //Display and use the No button
    26.             {
    27.                 Debug.Log("No");
    28.                 isOpen = false;
    29.                 buttonPressed = true;
    30.  
    31.             }
    32.         }
    33.     }
    34.  
    35.  
    36.  
    37.     // Start is called before the first frame update
    38.     void Start()
    39.     {
    40.  
    41.         // Will attach a VideoPlayer to the main camera.
    42.         GameObject camera = GameObject.Find("Main Camera");
    43.  
    44.         // VideoPlayer automatically targets the camera backplane when it is added
    45.         // to a camera object, no need to change videoPlayer.targetCamera.
    46.         videoPlayer = camera.AddComponent<UnityEngine.Video.VideoPlayer>();
    47.  
    48.         // Play on awake defaults to true. Set it to false to avoid the url set
    49.         // below to auto-start playback since we're in Start().
    50.         videoPlayer.playOnAwake = false;
    51.  
    52.         // By default, VideoPlayers added to a camera will use the far plane.
    53.         // Let's target the near plane instead.
    54.         videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraNearPlane;
    55.  
    56.         // This will cause our Scene to be visible through the video being played.
    57.         videoPlayer.targetCameraAlpha = 0.5F;
    58.  
    59.         // Set the video to play. URL supports local absolute or relative paths.
    60.         // Here, using absolute.
    61.         videoPlayer.url = "Assets/Zoolikon.mp4";
    62.  
    63.         // Skip the first 100 frames.
    64.         videoPlayer.frame = 100;
    65.  
    66.         // Restart from beginning when done.
    67.         videoPlayer.isLooping = false;
    68.  
    69.         // Each time we reach the end, we slow down the playback by a factor of 10.
    70.         //videoPlayer.loopPointReached += EndReached;
    71.  
    72.         // Start playback. This means the VideoPlayer may have to prepare (reserve
    73.         // resources, pre-load a few frames, etc.). To better control the delays
    74.         // associated with this preparation one can use videoPlayer.Prepare() along with
    75.         // its prepareCompleted event.
    76.         videoPlayer.Play();
    77.     }
    78.  
    79.     // Update is called once per frame
    80.     void Update()
    81.     {
    82.         print(videoPlayer.time);
    83.  
    84.         print(videoPlayer.time);
    85.         if (videoPlayer.time >= 5.0 && buttonPressed == false) {
    86.             print("paused;");
    87.             videoPlayer.Pause();
    88.             isOpen = true;   //Set the buttons to appear
    89.         }
    90.  
    91.     }
    92. }
    93.