RenderHeads / UnityPlugin-AVProVideo

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

Crash when changing PlatformOptionsAndroid on AVPro-v3 #1838

Closed Last8Exile closed 1 week ago

Last8Exile commented 2 months ago

Describe the issue Application crashes when changing any setting in MediaPlayer.PlatfrormOptionsAndroid. Crash happens when libAVProVideo2Native.so tries to call Java method com.renderheads.AVPro.Video.Manager.Player_SetPlayerSettings with invalid signature. Check crash log for details.

Your Setup (please complete the following information):

To Reproduce

  1. Prepare fresh instance of MediaPlayer 1.1. Make sure it does not open or play any media
  2. Wait for player initialisation (1 second is enough)
  3. From script change any option in MediaPlayer.PlatfrormOptionsAndroid 3.1. for example set different audio mode: _player.PlatfrormOptionsAndroid.audioMode = MediaPlayer.PlatformOptions.AudioMode.Unity;
  4. Observe crash during next Update() cycle

Logs

logcat ``` Aborting thread: "UnityMain" prio=5 tid=18 Native | group="" sCount=0 ucsCount=0 flags=0 obj=0x12cc1568 self=0xdc34e010 | sysTid=8668 nice=0 cgrp=default sched=0/0 handle=0xdee9be80 | state=R schedstat=( 3195901855 47372849 888 ) utm=298 stm=20 core=6 HZ=100 | stack=0xded99000-0xded9b000 stackSize=1035KB | held mutexes= "abort lock" "mutator lock"(shared held) native: #00 pc 00497913 /apex/com.android.art/lib/libart.so (art::DumpNativeStack+134) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #01 pc 0051113b /apex/com.android.art/lib/libart.so (art::Thread::DumpStack const+126) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #02 pc 0021c5a9 /apex/com.android.art/lib/libart.so (art::Thread::DumpStack const+112) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #03 pc 004f766b /apex/com.android.art/lib/libart.so (art::AbortState::DumpThread const+26) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #04 pc 004f2437 /apex/com.android.art/lib/libart.so (art::Runtime::Abort+2314) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #05 pc 00023837 /apex/com.android.art/lib/libbase.so (android::base::SetAborter::$_0::__invoke+46) (BuildId: 19bd36443b2e34de37977aa8e0ff152d) native: #06 pc 000230d7 /apex/com.android.art/lib/libbase.so (android::base::LogMessage::~LogMessage+226) (BuildId: 19bd36443b2e34de37977aa8e0ff152d) native: #07 pc 00254939 /apex/com.android.art/lib/libart.so (art::JavaVMExt::JniAbort+1972) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #08 pc 00254153 /apex/com.android.art/lib/libart.so (art::JavaVMExt::JniAbortV+54) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #09 pc 003fd229 /apex/com.android.art/lib/libart.so (art::::ScopedCheck::AbortF +40) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #10 pc 001eb447 /apex/com.android.art/lib/libart.so (art::::ScopedCheck::CheckMethodAndSig +314) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #11 pc 001ea3b9 /apex/com.android.art/lib/libart.so (art::::CheckJNI::CallMethodV +224) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #12 pc 003f1e27 /apex/com.android.art/lib/libart.so (art::::CheckJNI::CallStaticIntMethodV +42) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) native: #13 pc 0001a26d /data/app/~~MADFFSF08P4eqxEJtK1vLg==/com.ITS.Test-0tFx2ZfE05B-37r7XcGlWw==/lib/arm/libAVProVideo2Native.so (???) (BuildId: 2cec052d80dd1993f5b131faad50cd30e7ad23bb) native: #14 pc 0001ba85 /data/app/~~MADFFSF08P4eqxEJtK1vLg==/com.ITS.Test-0tFx2ZfE05B-37r7XcGlWw==/lib/arm/libAVProVideo2Native.so (AVPPlayerSetPlayerSettings+148) (BuildId: 2cec052d80dd1993f5b131faad50cd30e7ad23bb) native: #15 pc 00003dde (???) at com.unity3d.player.UnityPlayer.nativeRender(Native method) at com.unity3d.player.UnityPlayer.-$$Nest$mnativeRender(unavailable:0) at com.unity3d.player.UnityPlayer$F$a.handleMessage(unavailable:122) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at com.unity3d.player.UnityPlayer$F.run(unavailable:24) JNI DETECTED ERROR IN APPLICATION: the return type of CallStaticIntMethodV does not match void com.renderheads.AVPro.Video.Manager.Player_SetPlayerSettings(int, boolean, int, int, int, boolean, boolean) in call to CallStaticIntMethodV from boolean com.unity3d.player.UnityPlayer.nativeRender() ```
Chris-RH commented 2 months ago
  1. Does this occur in both Vulkan and OpenGLES?
  2. Does this occur in both Exoplayer and Android Mediaplayer?
  3. Does it only occur when you change by script or also when you change on the component?
Last8Exile commented 2 months ago

1 and 2. I will try different graphics and media APIs on 2024 May 02.

  1. This question is incorrect. Changing settings on component is imposible when application is running on Android (because the is no Unity Editor). Media player inspector is hiding PlatformSettings during play mode (can change playtform settings only through script during play mode or running on device). I tried using different settings on compent previously and it never crahed by itself. Crash happens only when I try to change PlatformSettigsAndroid from script (there is another crash with SeekAsync that reported in different issue).
Chris-RH commented 2 months ago

Are you making sure that you change before calling OpenMedia?

Last8Exile commented 2 months ago

I never call OpenMedia in this case. Crash happens without opening any video. Just changing settings of MediaPlayer instance. Please, wait to 2024 May 02. I will test everything again and triple confirm exact place where and why crash happens. I can send reproduction project if needed. There is a small chance that crash related to Java code stripping.

It will be same perproduction project as in https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/1836 but with one additional button which calls _player.PlatfrormOptionsAndroid.audioMode = MediaPlayer.PlatformOptions.AudioMode.Unity;

Last8Exile commented 2 months ago
  • Does this occur in both Vulkan and OpenGLES?
  • Does this occur in both Exoplayer and Android Mediaplayer?

Yes to all. I tested 4 combinations of graphics and mediap APIs. Settings that lead to crash is tied to OptionsAndroid._changed field. I tested with audioMode and preferredMaximumResolution. And i tested both Mono and IL2CPP scripting backends.

And sligly different crashlog:

logcat ``` *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'google/bluejay/bluejay:14/AP1A.240305.019.A1/11445699:user/release-keys' Revision: 'MP1.0' ABI: 'arm' Timestamp: 2024-05-02 09:49:43.278416600+0200 Process uptime: 33s Cmdline: com.ITS.Test pid: 25356, tid: 25377, name: UnityMain >>> com.ITS.Test <<< uid: 10410 signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- Abort message: 'JNI DETECTED ERROR IN APPLICATION: the return type of CallStaticIntMethodV does not match void com.renderheads.AVPro.Video.Manager.Player_SetPlayerSettings(int, boolean, int, int, int, boolean, boolean) in call to CallStaticIntMethodV from boolean com.unity3d.player.UnityPlayer.nativeRender()' r0 00000000 r1 00006321 r2 00000006 r3 def898a8 r4 def898b8 r5 def898a0 r6 0000630c r7 0000016b r8 00000000 r9 ffffffff r10 def898a8 r11 0000000b ip 00006321 sp def89888 lr e8ffcfdf pc e8ffcff2 13 total frames backtrace: #00 pc 0003cff2 /apex/com.android.runtime/lib/bionic/libc.so (abort+138) (BuildId: 8ee441f831d5c0dc55f3c5ce7f6961f9) #01 pc 004f206f /apex/com.android.art/lib/libart.so (art::Runtime::Abort(char const*)+1346) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) #02 pc 00023837 /apex/com.android.art/lib/libbase.so (android::base::SetAborter(std::__1::function&&)::$_0::__invoke(char const*)+46) (BuildId: 19bd36443b2e34de37977aa8e0ff152d) #03 pc 000230d7 /apex/com.android.art/lib/libbase.so (android::base::LogMessage::~LogMessage()+226) (BuildId: 19bd36443b2e34de37977aa8e0ff152d) #04 pc 00254939 /apex/com.android.art/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1972) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) #05 pc 00254153 /apex/com.android.art/lib/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+54) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) #06 pc 003fd229 /apex/com.android.art/lib/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...) (.__uniq.99033978352804627313491551960229047428)+40) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) #07 pc 001eb447 /apex/com.android.art/lib/libart.so (art::(anonymous namespace)::ScopedCheck::CheckMethodAndSig(art::ScopedObjectAccess&, _jobject*, _jclass*, _jmethodID*, art::Primitive::Type, art::InvokeType) (.__uniq.99033978352804627313491551960229047428)+314) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) #08 pc 001ea3b9 /apex/com.android.art/lib/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType) (.__uniq.99033978352804627313491551960229047428)+224) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) #09 pc 003f1e27 /apex/com.android.art/lib/libart.so (art::(anonymous namespace)::CheckJNI::CallStaticIntMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list) (.__uniq.99033978352804627313491551960229047428.llvm.3385106412004782044)+42) (BuildId: 9d2fb319cd1279742bba25d07f1d77c2) #10 pc 0001a26d /data/app/~~x-w86LZIi_1kMOXSfM4Eyw==/com.ITS.Test-QyoxrnHUz3qwlE4Yyi-clA==/lib/arm/libAVProVideo2Native.so (BuildId: 2cec052d80dd1993f5b131faad50cd30e7ad23bb) #11 pc 0001ba85 /data/app/~~x-w86LZIi_1kMOXSfM4Eyw==/com.ITS.Test-QyoxrnHUz3qwlE4Yyi-clA==/lib/arm/libAVProVideo2Native.so (AVPPlayerSetPlayerSettings+148) (BuildId: 2cec052d80dd1993f5b131faad50cd30e7ad23bb) #12 pc 0000181e ```
rrenderr commented 1 month ago

Hi @Chris-RH . I have same problem, and same steps to reproduce. Do you have any updates?

Ste-RH commented 3 weeks ago

This might have been fixed in v3.0.2. I cannot reproduce it here with the latest version.

Would it be possible for you to update, re-test, and report back @Last8Exile ?

Last8Exile commented 3 weeks ago

@Ste-RH I don't have spare time this week. I will try to check issues opened by me at 2024.06.17

dw8869 commented 3 weeks ago

@Ste-RH It is also reproduced in v3.0.2, and the error below occurs.

java_vm_ext.cc:579] JNI DETECTED ERROR IN APPLICATION: the return type of CallStaticIntMethodV does not match void
com.renderheads.AVPro.Video.Manager.Player_SetPlayerSettings(int, boolean, int, int, int, int, boolean, boolean)
java_vm_ext.cc:579]     in call to CallStaticIntMethodV
java_vm_ext.cc:579]     from boolean com.unity3d.player.UnityPlayer.nativeRender()
Ste-RH commented 2 weeks ago

Hopefully this will be fixed in v3.0.3

Chris-RH commented 2 weeks ago

AVPro Video version 3.0.3 has been released. Please let us know if the issue has been fixed :)

dw8869 commented 2 weeks ago

In my case, still crashed on v3.0.3.

20:06:06.786  8091-8368  AVProVideo com...al.jumpvrm  D  🐞 (com_renderheads_AVProVideo.cpp:902) AVPPluginMakePlayer - settings: {
                                                           .api = 2,
                                                           .pixelFormat = 1,
                                                           .videoFlags = 0x00000000,
                                                           .preferredMaximumResolution_width = 0.000000,
                                                           .preferredMaximumResolution_height = 0.000000,
                                                           .maximumPlaybackRate = 0.000000,
                                                           .audioOutputMode = 1,
                                                           .sampleRate = 48000,
                                                           .bufferLength = 1024,
                                                           .audioFlags = 0x00000000,
                                                           .audio360Channels = 0,
                                                           .audio360LatencyMS = 0,
                                                           .preferredPeakBitRate = 0.000000,
                                                           .preferredForwardBufferDuration = 0.000000,
                                                           .networkFlags = 0x00000000,
                                                           .minBufferMs = 50000,
                                                           .maxBufferMs = 50000,
                                                           .bufferForPlaybackMs = 2500,
                                                           .bufferForPlaybackAfterRebufferMs = 5000
                                                         }
20:06:06.859  8091-8368  Conn...ger com...al.jumpvrm  D  StackLog: [android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:3925)] [android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4489)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4456)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4430)] [androidx.media3.exoplayer.scheduler.RequirementsWatcher.registerNetworkCallbackV24(RequirementsWatcher.java:137)] [androidx.media3.exoplayer.scheduler.RequirementsWatcher.start(RequirementsWatcher.java:92)] [androidx.media3.exoplayer.offline.DownloadManager.<init>(DownloadManager.java:264)] [androidx.media3.exoplayer.offline.DownloadManager.<init>(DownloadManager.java:216)] [com.renderheads.AVPro.Video.Player_ExoPlayer.InitialisePlayer(Unknown
                                                         Source:156)] [com.renderheads.AVPro.Video.Player_Base.Initialise(Unknown Source:92)] [com.renderheads.AVPro.Video.Manager.MakePlayer(Unknown
                                                         Source:127)] [com.unity3d.player.UnityPlayer.nativeRender(Native Method)] [com.unity3d.player.UnityPlayer.access$300(Unknown
                                                         Source:0)] [com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)]
20:06:06.908  8091-8368  Unity      com...al.jumpvrm  I  playerID: 00007857
                                                         RenderHeads.Media.AVProVideo.PlatformMediaPlayer:CreateCommandBuffers()
                                                         RenderHeads.Media.AVProVideo.PlatformMediaPlayer:.ctor(PlatformOptions)
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer(OptionsAndroid)
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer()
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:Initialise()
                                                         ifland.UCF.Media.Module.VideoPlayer:CreatePlayer(Transform)
                                                         ifland.UCF.Media.Module.VideoPlayer:.ctor(Transform, IVideoEventHandler)
                                                         ifland.UCF.Media.Service.VideoProvider:Initialize(IMediaModuleEventHandler, Material)
                                                         ifland.UCF.Media.Service.MediaProvider:EnsureMediaProvider(MediaUser, LandMediaData, Action`1)
                                                         ifland.UCF.Media.Service.MediaService:SyncMediaData(iflandUser, LandMediaData, Boolean, Action`1)
                                                         ifland.UCF.App.ServiceController.<PresentationSetup>d__2:MoveNext()
                                                         UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
20:06:06.909  8091-8368  Unity      com...al.jumpvrm  I  flags: 00000000
                                                         RenderHeads.Media.AVProVideo.PlatformMediaPlayer:CreateCommandBuffers()
                                                         RenderHeads.Media.AVProVideo.PlatformMediaPlayer:.ctor(PlatformOptions)
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer(OptionsAndroid)
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer()
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:Initialise()
                                                         ifland.UCF.Media.Module.VideoPlayer:CreatePlayer(Transform)
                                                         ifland.UCF.Media.Module.VideoPlayer:.ctor(Transform, IVideoEventHandler)
                                                         ifland.UCF.Media.Service.VideoProvider:Initialize(IMediaModuleEventHandler, Material)
                                                         ifland.UCF.Media.Service.MediaProvider:EnsureMediaProvider(MediaUser, LandMediaData, Action`1)
                                                         ifland.UCF.Media.Service.MediaService:SyncMediaData(iflandUser, LandMediaData, Boolean, Action`1)
                                                         ifland.UCF.App.ServiceController.<PresentationSetup>d__2:MoveNext()
                                                         UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
20:06:06.910  8091-8368  Unity      com...al.jumpvrm  I  flags: 00007857
                                                         RenderHeads.Media.AVProVideo.PlatformMediaPlayer:CreateCommandBuffers()
                                                         RenderHeads.Media.AVProVideo.PlatformMediaPlayer:.ctor(PlatformOptions)
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer(OptionsAndroid)
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer()
                                                         RenderHeads.Media.AVProVideo.MediaPlayer:Initialise()
                                                         ifland.UCF.Media.Module.VideoPlayer:CreatePlayer(Transform)
                                                         ifland.UCF.Media.Module.VideoPlayer:.ctor(Transform, IVideoEventHandler)
                                                         ifland.UCF.Media.Service.VideoProvider:Initialize(IMediaModuleEventHandler, Material)
                                                         ifland.UCF.Media.Service.MediaProvider:EnsureMediaProvider(MediaUser, LandMediaData, Action`1)
                                                         ifland.UCF.Media.Service.MediaService:SyncMediaData(iflandUser, LandMediaData, Boolean, Action`1)
                                                         ifland.UCF.App.ServiceController.<PresentationSetup>d__2:MoveNext()
                                                         UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
20:06:06.918  8091-8368  t.tr...pvr com...al.jumpvrm  A  java_vm_ext.cc:579] JNI DETECTED ERROR IN APPLICATION: the return type of CallStaticIntMethodV does not match void
                                                         com.renderheads.AVPro.Video.Manager.Player_SetPlayerSettings(int, boolean, int, int, int, boolean, boolean)
                                                         java_vm_ext.cc:579]     in call to CallStaticIntMethodV
                                                         java_vm_ext.cc:579]     from boolean com.unity3d.player.UnityPlayer.nativeRender()
Chris-RH commented 2 weeks ago

hmmm, that's a shame. Could you attach a full, unedited logcat as a txt file please

dw8869 commented 2 weeks ago

Here is log. logcat.txt

Ste-RH commented 2 weeks ago

Thanks for the log @dw8869. It has showed exactly where the issue is and we have now put a fix in for it. This will be available in the next build (v3.0.4) which we hope to have out by the end of the week.

dw8869 commented 2 weeks ago

@Ste-RH Can I get the version before it was released? There are many things that I couldn't check due to this error.

rrenderr commented 2 weeks ago

Still same for me. I'm waiting 3.0.4

Chris-RH commented 1 week ago

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

dw8869 commented 1 week ago

The issue seems to have been fixed. It cannot be reproduced.