UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

[iOS] Coroutine couldn't be started because the the game object 'MediaPlayer' is inactive!

Open sgm55 opened this issue 8 months ago • 10 comments

Unity version

6000.0.41f1

Unity editor platform

macOS

AVPro Video edition

Core

AVPro Video version

3.2.4

Device hardware

iPhone XR

Which iOS version are you using?

17

Texture format

BGRA

Audio output

System Direct

Any other Media Player component configuration required to reproduce the issue.

Using media player with Display uGUI to display video in Canvas

Which output component(s) are you using?

Display uGUI

Any other component configuration required to reproduce the issue.

No response

The issue

Hello, I am currently loading and playing a local video on a UI Canvas in Unity using: bool isOpening = mediaPlayer.OpenMedia(new MediaPath(contentUrl, MediaPathType.AbsolutePathOrURL), autoPlay: true);

However, if the parent gameObject is disabled quickly before the video is loaded and played in the canvas, I get the following below error : Coroutine couldn't be started because the the game object 'MediaPlayer' is inactive! UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator) RenderHeads.Media.AVProVideo.MediaPlayer:StartRenderCoroutine () (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:1023) RenderHeads.Media.AVProVideo.MediaPlayer:InternalOpenMedia () (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:638) RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:535) RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (RenderHeads.Media.AVProVideo.MediaPathType,string,bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:514) RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (RenderHeads.Media.AVProVideo.MediaPath,bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:505)

This in turn makes my game crash.

The issue occurs on iOS & Android builds, as well as in the editor while in Play mode.

I have tried wrapping the mediaPlayer.OpenMedia inside a try-catch method, but the error still occurs.

Is there anything that I can do to avoid this error? Ideally, if the gameObject is not active, then I'd simply let the video load without autoplay

Media information

No response

Log output

Coroutine couldn't be started because the the game object 'MediaPlayer' is inactive!
UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
RenderHeads.Media.AVProVideo.MediaPlayer:StartRenderCoroutine () (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:1023)
RenderHeads.Media.AVProVideo.MediaPlayer:InternalOpenMedia () (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:638)
RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:535)
RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (RenderHeads.Media.AVProVideo.MediaPathType,string,bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:514)
RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (RenderHeads.Media.AVProVideo.MediaPath,bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:505)

sgm55 avatar Apr 08 '25 23:04 sgm55

What is your reason for disabling the parent gameObject? Are you able to provide your crash logs please?

Chris-RH avatar Apr 09 '25 08:04 Chris-RH

Sure, so there are several reasons:

  1. User is presented a pop-up in the UI with the video. The user then closes the pop-up or skips the video before it loads, resulting in the error.

  2. User is presented with a scrollview of tutorial videos. When the user scrolls, the video at the top starts to autoplay. The scrollview uses object pooling for performance issues. So, if the users swipes quickly to reach the bottom videos, the top gameObjects are recycled. In this case, the parent gameObject is disabled and re-enabled for pooling before the video finishes loading.

sgm55 avatar Apr 09 '25 19:04 sgm55

Can you provide a full, unfiltered logcat please

Chris-RH avatar Apr 10 '25 13:04 Chris-RH

So we have currently discontinued Android builds for other reasons. We have iOS and the issue also occurs in the editor. Is there anything else I can share from the editor for example?

sgm55 avatar Apr 11 '25 02:04 sgm55

Can you provide a full, unfiltered logcat please

Chris-RH avatar Apr 11 '25 09:04 Chris-RH

Is the logcat only available from Android? If so, I cannot provide a full logcat right now as Android has been discontinued. Is there an equivalent for iOS or editor?

sgm55 avatar Apr 12 '25 06:04 sgm55

This issue has been fixed. We now check for the game object being active before starting the render coroutine in the OpenMedia call.

This fix will make it into the next release.

MorrisRH avatar Apr 22 '25 13:04 MorrisRH

AVPro Video version 3.2.5 has been released. Please let us know if it has not fixed your issue.

Chris-RH avatar Apr 24 '25 16:04 Chris-RH

Hello, thank you very much for this and apologies for the late reply. Due to several factors we were not able to upgrade the AVPro Video version until now. We updated to the current latest release (v3.2.6) and the issue still persists.

Running this in the Editor with v3.2.6-trial build we get the following: Coroutine couldn't be started because the the game object 'MediaPlayer' is inactive! UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator) RenderHeads.Media.AVProVideo.MediaPlayer:StartRenderCoroutine () (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:1028) RenderHeads.Media.AVProVideo.MediaPlayer:InternalOpenMedia () (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:638) RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:535) RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (RenderHeads.Media.AVProVideo.MediaPathType,string,bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:514) RenderHeads.Media.AVProVideo.MediaPlayer:OpenMedia (RenderHeads.Media.AVProVideo.MediaPath,bool) (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:505)

sgm55 avatar May 31 '25 07:05 sgm55

This should be fixed in the next release, version 3.2.7.

MorrisRH avatar Jun 10 '25 08:06 MorrisRH

AVPro Video version 3.2.7 has been released. Please let us know if this has not fixed the issue for you.

Chris-RH avatar Jul 03 '25 08:07 Chris-RH