RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
232 stars 28 forks source link

[Android] When playing multiple videos in the scene, a crash occurs intermittently with the log below. #1940

Closed vvhustle closed 2 months ago

vvhustle commented 2 months ago

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Describe the issue When playing a video on a specific Android device, the app crashes by spitting out the following logs.

Your Setup (please complete the following information):

To Reproduce

Logs If applicable, add error logs to help explain your problem.

Attach Log Files avpro.txt

Screenshots If applicable, add screenshots to help explain your problem.

Videos If applicable, add a copy of your video or the URL

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Instead email the link to us unitysupport@renderheads.com

Chris-RH commented 2 months ago

You've note given any details as to the specs of the videos that you are trying to play, or how many you are trying to play at once.

The fundamental problem is that some devices cannot play multiple videos at once. Some Android devices can only provide only one decoder instance at a time to an app, some can offer multiple but with a limit. This varies per device and there is no consistent behavior (as of Android 12 there is some improvement - see next paragraph). ExoPlayer takes a conservative approach, and only occupies one codec instance at a time, e.g. when moving between items in a playlist ExoPlayer makes sure to first release a codec before acquiring the next one.

The general suggestion is to ensure you have only one player instance at a time playing video, if not having one instance in total in your app. On Android 12, the platform introduced the performance class by which an app can figure out if the device can provide multiple decoders concurrently, hence the app can do multiple playbacks.

So, you need to make very sure that you are closing the video and releasing the codec before moving on to the next one.

Additionally, each media player instance will require hardware resources which are limited and will eventually run out which is why you're seeing things stop working. The decoder resources and texture memory required will be based on the resolution and frame rate of the video being decoded so you could look to use smaller videos to try and increase the number of active media players you can use.

vvhustle commented 2 months ago

Thank you for your quick response. It was logic with up to 9 mediaplayers playing videos at a time in the game script. One additional question is that in avpro 2 version, there was no problem with that logic, and I was wondering if there was any change to the change in 2->3. (There was a problem before, but maybe I just checked it out.)

vvhustle commented 2 months ago

also I attached firebase log

Caused by java.lang.NullPointerException Attempt to read from field 'int com.renderheads.AVPro.Video.Player_Base$VideoCommand._command' on a null object reference

Caused by java.lang.NullPointerException: Attempt to read from field 'int com.renderheads.AVPro.Video.Player_Base$VideoCommand._command' on a null object reference at com.renderheads.AVPro.Video.Player_Base.UpdateCommandQueue(:28) at com.renderheads.AVPro.Video.Player_Base.Update(:100) at com.renderheads.AVPro.Video.Manager$1.run(:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8751) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Chris-RH commented 2 months ago

There were several changes between version 2 and 3, what do you mean specifically? I'm confused, that's different to the previous log?

vvhustle commented 2 months ago

Sorry for causing trouble. The first log file is an error identified by ADB, and the second log file is a null exception that was reported to Firebase crashlytics. In version 2 avpro, we inquired about the changes between versions because multiple videos were played properly at the same time. First, we will reduce the number of mediaaplayers inside the script and fix it.

vvhustle commented 2 months ago

Previously, I called the OpenMedia() in Awake, but when I moved it to OnEnable, it works fine. I'll close the issue. Thank you