Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to create player #37

Closed
crazylulu9999 opened this issue Apr 2, 2019 · 22 comments
Closed

Failed to create player #37

crazylulu9999 opened this issue Apr 2, 2019 · 22 comments
Assignees
Labels
Android Android platform Bug 🐛 Something isn't working

Comments

@crazylulu9999
Copy link

Describe the bug
Using AVPro Video for splash scene.
Quit app and restart app quickly then "Failed to create player".

Your Setup (please complete the following information):

  • Unity version: 2018.3.11f1
  • AVPro Video version: 1.9.12
  • Operating system version: Android 8.1.0
  • Device model: Redmi Note 5
  • Video specs (resolution, frame-rate, codec, file size): Any

To Reproduce

  1. Quit app using Application.Quit()
  2. Re-start app quickly

Logs

[AVProVideo] Failed to create player instance 
UnityEngine.Logger:Log(LogType, Object)
RenderHeads.Media.AVProVideo.AndroidMediaPlayer:.ctor(Boolean, Boolean, VideoApi, Boolean, Audio360ChannelMode, Boolean)
RenderHeads.Media.AVProVideo.MediaPlayer:CreatePlatformMediaPlayer()
RenderHeads.Media.AVProVideo.MediaPlayer:Initialise()
RenderHeads.Media.AVProVideo.MediaPlayer:Start()

[AVProVideo] Initialising AVPro Video (script v1.9.12 plugin v1.9.10) on Adreno (TM) 509/OpenGL ES 3.2 V@269.0 (GIT@a1355e2, I141a912644) (Date:04/18/18) (MT True) on Android 
UnityEngine.Logger:Log(LogType, Object)
RenderHeads.Media.AVProVideo.MediaPlayer:Initialise()
RenderHeads.Media.AVProVideo.MediaPlayer:Start()

[AVProVideo] Opening jar:file:///data/app/com.test.app-jOTKGt8J8Fpxlbv1qx4j1Q==/base.apk!/assets/video/downloaded_from_google_play.mp4 (offset 0) 
UnityEngine.Debug:Log(Object, Object)
RenderHeads.Media.AVProVideo.MediaPlayer:OpenVideoFromFile()
<PlayCoroutine>d__8:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

[AVProVideo] m_Video is null! 
UnityEngine.Logger:Log(LogType, Object)
RenderHeads.Media.AVProVideo.AndroidMediaPlayer:OpenVideoFromFile(String, Int64, String, UInt32, UInt32, Int32)
RenderHeads.Media.AVProVideo.MediaPlayer:OpenVideoFromFile()
<PlayCoroutine>d__8:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

[AVProVideo] Failed to open jar:file:///data/app/com.test.app-jOTKGt8J8Fpxlbv1qx4j1Q==/base.apk!/assets/video/downloaded_from_google_play.mp4 
UnityEngine.Debug:LogError(Object, Object)
RenderHeads.Media.AVProVideo.MediaPlayer:OpenVideoFromFile()
<PlayCoroutine>d__8:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Instead email the link to us unitysupport@renderheads.com

@crazylulu9999 crazylulu9999 added the Bug 🐛 Something isn't working label Apr 2, 2019
@AndrewRH AndrewRH added the Android Android platform label May 9, 2019
@parmaia
Copy link

parmaia commented May 17, 2019

Hello!

I'm facing the exact same issue. If I close the app with Application.Quit(); during the video play, then I can re open it with no problem. If I close the app after the video finishes playing, then I got the message: "[AVProVideo] Failed to create player instance".

@AndrewRH
Copy link
Contributor

We've just released a new version of AVPro Video (v.1.9.17) which should fix this issue. Please do test it and let us know if if this resolves it for you.

Thanks,

@Ste-RH Ste-RH self-assigned this Jun 14, 2019
@AndrewRH
Copy link
Contributor

We'll close this issue in a couple of days, as we've proposed a solution (new plugin version) but haven't heard anything back. If you're still having this issue with the new version please do let us know.

Thanks,

@joker-gizmo
Copy link

joker-gizmo commented Jun 20, 2019

The issue still persist after update.

My setup:

Unity version: 2018.4.2f1
AVPro Video version: 1.9.17
Operating system version: Android 8.0.0
Device model: Samsung S8

2019-06-20 19:03:52.928 15070-15387/com.GizmoVR.GizmoVR E/Unity: [AVProVideo] Failed to create player instance
RenderHeads.Media.AVProVideo.AndroidMediaPlayer:.ctor(Boolean, Boolean, VideoApi, Boolean, Audio360ChannelMode, Boolean)
RenderHeads.Media.AVProVideo.MediaPlayer:CreatePlatformMediaPlayer()
RenderHeads.Media.AVProVideo.MediaPlayer:Initialise()
RenderHeads.Media.AVProVideo.MediaPlayer:Start()
2019-06-20 19:03:52.942 15070-15387/com.GizmoVR.GizmoVR I/Unity: [AVProVideo] Initialising AVPro Video (script v1.9.17 plugin v1.9.17) on Mali-G71/OpenGL ES 3.2 v1.r9p0-01rel0.2498e584901afb9257be0d365ada85fa (MT False) on Android
RenderHeads.Media.AVProVideo.Helper:LogInfo(String, Object)
RenderHeads.Media.AVProVideo.MediaPlayer:Initialise()
RenderHeads.Media.AVProVideo.MediaPlayer:Start()

@AndrewRH
Copy link
Contributor

@joker-gizmo
Thanks for reporting this - could you provide more details on how to replicate this issue?

@joker-gizmo
Copy link

The problem was with another native plugin which is not terminate their thread correctly on quit. There was a bunch of errors on quit and after restart no one plugin was able to init. Sorry, for misleading you

@AndrewRH AndrewRH added self resolved The user fixed the issue themselves and removed Bug 🐛 Something isn't working labels Jun 26, 2019
@AndrewRH
Copy link
Contributor

Great to hear you found the issue, i'll close this ticket now

@parmaia
Copy link

parmaia commented Jul 3, 2019

Hi!

Sorry for the delayed response.

I tested the new version (1.9.17) and have to say that the problem is still present. I made a small test project to show the issue, and realized that I'm when the video ends I disable the GameObject with the MediaPlayer attached and that is causing the problem. If I don't disable the GameObject or quit the app before the video ends, all goes fine.

To reproduce:

  1. Create a new project and import AvPro 1.9.17.
  2. Add a MediaPlayer, a Display UGui and link them so a video can be viewed. For simplicity let AutoOpen and AutoPlay to true. Add a video (any from StreamingAssets will work).
  3. Create a GameObject and attach this script:
using RenderHeads.Media.AVProVideo;
using UnityEngine;
    
public class Manager : MonoBehaviour{
    public MediaPlayer player;

    void Start() {
        player.Events.AddListener(PlayerEvent);
    }

    void Update() {
        if(Input.GetKeyDown(KeyCode.Escape)){
            Application.Quit();
        }
    }

    public void PlayerEvent(MediaPlayer player, MediaPlayerEvent.EventType eventType, ErrorCode error){
        switch(eventType){
            case MediaPlayerEvent.EventType.FinishedPlaying:
                player.CloseVideo(); // The problem occurs regardless of this line
                player.gameObject.SetActive(false); // <-- If you remove this line, the problem dissapears.
            break;
        }
    }    
}
  1. Attach the script to the new GameObject.
  2. Attach the MediaPlayer to the Manager script.
  3. Compile and run the app on Android.
  4. When the app start, let the video play to the end and press back button to quit the app.
  5. Launch the app again, the app will freeze and the logcat shows:
    [AVProVideo] Failed to create player instance

If you want I can send you the project I made to test it.

Thanks!

@ColorTwist
Copy link

ColorTwist commented Sep 30, 2019

Also receiving this issue on Android 9 with unity 2019.1.11f, happens always after Application.Quit(); and returning and running the game again. very annoying to players.
using the latest version 1.10.0
If closing the app using the home button, it seems the videos are working and i do not get this error.

Any fix for this or maybe should i use something to dipose AVPRO on Application.quit?

09-30 21:08:56.848: E/Unity(5478): Unable to find libc
09-30 21:08:56.882: E/Unity(5478): [AVProVideo] Failed to create player instance
09-30 21:08:56.882: E/Unity(5478): RenderHeads.Media.AVProVideo.AndroidMediaPlayer:.ctor(Boolean, Boolean, VideoApi, Boolean, Audio360ChannelMode, Boolean)
09-30 21:08:56.882: E/Unity(5478): RenderHeads.Media.AVProVideo.MediaPlayer:CreatePlatformMediaPlayer()
09-30 21:08:56.882: E/Unity(5478): RenderHeads.Media.AVProVideo.MediaPlayer:Initialise()
09-30 21:08:56.882: E/Unity(5478): RenderHeads.Media.AVProVideo.MediaPlayer:Start()
09-30 21:08:56.882: E/Unity(5478):
09-30 21:08:56.882: E/Unity(5478): (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 48)

@AndrewRH AndrewRH reopened this Oct 2, 2019
@AndrewRH
Copy link
Contributor

AndrewRH commented Oct 2, 2019

Hmm...seems that this issue is still happening (sorry we only noticed now as we don't get notifications on Closed issues)

@ColorTwist
Copy link

Yes, it does :\ Whatever I tried to clean AVProVideo before quit game did not work.

@ColorTwist
Copy link

Any update on this?
I'll do note that I do open a few instances of AVProVideo in order to pre-prepare a video in a sequence.
If I Application.Quit() without init any video the problem does not occur.

@parmaia
Copy link

parmaia commented Oct 14, 2019

Hi,

I can confirm that this is still happening.

My workarround was to quit the app using Android native code:

    public static void QuitApp(){
    #if UNITY_ANDROID
        AndroidJavaClass player = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject androidActivity = player.GetStatic<AndroidJavaObject>("currentActivity");
        if(androidActivity!=null){
           androidActivity.Call("finishAffinity");
           AndroidJavaClass system = new AndroidJavaClass("java.lang.System");
           system.CallStatic("exit", new object[]{0});
        }
    #else
        Application.Quit();
    #endif
    }

This is working on Unity 2019.1.14f1, Unity 2018.4.2f1, on Android 8 and 9.

@ColorTwist
Copy link

ColorTwist commented Oct 14, 2019

@parmaia thanks for the update. I less prefer this solution, but it's better than nothing until fixed.
I'll try it out.

@ColorTwist
Copy link

ColorTwist commented Oct 14, 2019

@parmaia For some reason, i get an error on:
AndroidJavaClass System = AndroidNativeInterface.GetClass("java.lang.System");
'AndroidNativeInterface' does not exist in the current context
When compling to APK

@parmaia
Copy link

parmaia commented Oct 15, 2019

@ColorTwist sorry, I kind of messed up with my sample code. I have a class for native calls and one line went into my sample code.

This is the good code:

    public static void QuitApp(){
    #if UNITY_ANDROID
        AndroidJavaClass player = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject androidActivity = player.GetStatic<AndroidJavaObject>("currentActivity");
        if(androidActivity!=null){
           androidActivity.Call("finishAffinity");
           AndroidJavaClass system = new AndroidJavaClass("java.lang.System");
           system.CallStatic("exit", new object[]{0});
        }
    #else
        Application.Quit();
    #endif
    }

I tested this on Unity 2018.4.2f1 and Untiy 2019.1.14f1 and on Android 8 and Android 9.

Again, sorry for the mistake.

@nsmith1024
Copy link

I have this problem too, but I dont have any native code, is there way to do it from C# in unity?

@parmaia
Copy link

parmaia commented Feb 6, 2020

@nsmith1024 You can use the QuitApp() method in my previous comment. It is C#.

@nsmith1024
Copy link

OK, thanks i w ill try it, i was wondering should I replace "com.unity3d.player.UnityPlayer" with my app package name? what about "currentActivity" do i have to change that?

@stale
Copy link

stale bot commented Jul 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Stale label Jul 1, 2020
@AndrewRH AndrewRH removed self resolved The user fixed the issue themselves stale Stale labels Jul 1, 2020
@AndrewRH AndrewRH added the Bug 🐛 Something isn't working label Jul 1, 2020
@stale
Copy link

stale bot commented Aug 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Stale label Aug 26, 2020
@AndrewRH AndrewRH removed the stale Stale label Aug 26, 2020
@Ste-RH
Copy link
Collaborator

Ste-RH commented Jan 25, 2021

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android platform Bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants