RenderHeads / UnityPlugin-AVProVideo

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

App Crash after upgrade to V3.0 #1811

Closed eeease closed 3 months ago

eeease commented 6 months ago

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Describe the issue After updating to AVPro 3.0 Ultra, playback in our app causes the entire app to crash. We specifically upgraded to 3.0 in order to use Vulkan, but now our playback crashes the app in both Vulkan and OpenGLES3.

Your Setup (please complete the following information):

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

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Instead email the link to us unitysupport@renderheads.com

Any suggestions would be very helpful. I've been nonstop testing different variables for about a week. Thank you!

eeease commented 6 months ago

Runs fine in Editor, by the way. No problems loading any of the listed video files. Standalone Windows build also runs fine, plays back video without issue.

Chris-RH commented 5 months ago

Did you follow our upgrade steps? Can you reproduce this in a new project using only AVPro Video mediaplayer demo?

eeease commented 5 months ago

Yep, I followed the upgrade steps, thanks.

When I export a build with just AVPro Video Mediaplayer Demo, the mediaplayer opens on launch and plays through the video. Vulkan graphics API, Android 13. I tried with the Exo Player, BGRA and OES texture format options.

One thing I noticed is that even though I have the Oculus settings set to Multi Pass, the video player is only rendering in one eye (the right eye). I know there are a ton of variables at play here, so I'm not sure exactly which one(s) will make it play in both eyes.

On your end, is there anything useful to be gleaned from the attached logcat file?

Anton111111 commented 5 months ago

Yep, I followed the upgrade steps, thanks.

I have crash after upgrade too. But it doesn't work with OpenGLES3 but works with Vulkan ;) https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/1807

Did you try build Developer release? I have not crash in Developer release.

Hadrien-Estela commented 5 months ago

Experiencing same issue. I tried with vulkan but the quest app does not start if in build in dev mode.

https://issuetracker.unity3d.com/issues/quest-openxr-vulkan-application-stuck-on-loading-when-launching-on-meta-quest-2-slash-3-headset-with-development-build-enabled

eeease commented 5 months ago

Yep, I followed the upgrade steps, thanks.

I have crash after upgrade too. But it doesn't work with OpenGLES3 but works with Vulkan ;) #1807

Did you try build Developer release? I have not crash in Developer release.

I saw your ticket, yeah! Weird that mine broke with the switch to Vulkan and yours broke with the switch to OpenGLES3!

I have been making mostly development builds. However, I've tried release builds, too and they also crash when I load a video.

I've also tried having it connected or disconnected to my computer while running the app, since I read somewhere that being connected to logcat and/or Unity could cause some weird bugs.

eeease commented 5 months ago

@Chris-RH Any chance the crash has to do with line 803: java_vm_ext.cc:579] JNI DETECTED ERROR IN APPLICATION: JNI CallStaticVoidMethodV called with pending exception java.lang.IllegalArgumentException:

We're using Unity 2022.3.4f1 with Android tools that are "installed with Unity." It's not easy to parse exactly what JDK tools we're using but a notice in Preferences says "based on OpenJDK 11.0.14.1+1."

Oh, also, my Quest 2 device is on Software version 63. Apparently 64 just released this week but I'm not getting an option to update my device yet.

Chris-RH commented 5 months ago

Out of interest, have you tested this on any other android device?

eeease commented 5 months ago

Out of interest, have you tested this on any other android device?

So far, no, just Quest 2. I'll try to get my hands on a Quest 3 to test on that, too.

Chris-RH commented 5 months ago

Have you tried a vulkan build without AVPro in the project?

eeease commented 5 months ago

Have you tried a vulkan build without AVPro in the project?

Yes. It runs okay without AVPro.

I'm seeing a common link between all of my crashes - they all have some mention of java, JNI, and Seek is mentioned in the traces: image

Is there anything new in Version 3.0 that's happening with Seek that didn't happen in 2.x? I'm going to try to make a build with Seek disabled.

Last8Exile commented 5 months ago

On android application crashes on MediaPlayer.Control.SeekFast(). Crash does not happen on Seek(). I tested different cases and values. It always crashes with SeekFast().

Unity 2022.3.22f1 Devlopment Build AVPro v3.0.0f1-ultra armV7 Quest 2 Min SDK 29 Target SDK 32 Compile SDK 33

JNI DETECTED ERROR IN APPLICATION: JNI CallStaticVoidMethodV called with pending exception java.lang.IllegalArgumentException:
  at void androidx.media3.common.util.Assertions.checkArgument(boolean) (Assertions.java:40)
  at void androidx.media3.exoplayer.SeekParameters.<init>(long, long) (SeekParameters.java:71)
  at void com.renderheads.AVPro.Video.Player_ExoPlayer._seekWithTolerances(long, long, long) (SourceFile:-1)
  at void com.renderheads.AVPro.Video.Manager.Player_Seek(int, double, double, double) (SourceFile:-1)
  at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
  at boolean com.unity3d.player.UnityPlayer.-$$Nest$mnativeRender(com.unity3d.player.UnityPlayer) ((null):-1)
  at boolean com.unity3d.player.UnityPlayer$F$a.handleMessage(android.os.Message) ((null):-1)
  at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
  at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:214)
  at void android.os.Looper.loop() (Looper.java:304)
  at void com.unity3d.player.UnityPlayer$F.run() ((null):-1)

    in call to CallStaticVoidMethodV
    from boolean com.unity3d.player.UnityPlayer.nativeRender()
managed backtrace:
      #00 (wrapper managed-to-native) RenderHeads.Media.AVProVideo.PlatformMediaPlayer/Native:AVPPlayerUpdate (intptr)
      #01 RenderHeads.Media.AVProVideo.PlatformMediaPlayer:Update ()
      #02 RenderHeads.Media.AVProVideo.PlatformMediaPlayer:SeekWithTolerance (double,double,double) 
      #03 RenderHeads.Media.AVProVideo.PlatformMediaPlayer:SeekFast (double) 
      #04 VideoUtils.VideoPlayerImpl/<SeekAsync>d__58:MoveNext () // _player.Control.SeekFast(0);
eeease commented 5 months ago

Instead of upgrading from 2.x to 3.0, I just tried deleting the previous package completely then re-downloading and re-importing 3.0 ultra.

The same crash occurs upon playback - content plays for a second then the app crashes. OpenGLES3, Quest 2, Linear Color Space, ExoPlayer (BGRA).

tombstone file attached as txt file.

tombstone_newAVPro30Install.txt

Chris-RH commented 5 months ago

How does it work if you use Android Mediaplayer instead of Exoplayer?

eeease commented 5 months ago

How does it work if you use Android Mediaplayer instead of Exoplayer?

Could you point me to where that is? Is that a prefab? A script? The closest I see is Assets/AVProVideo/Runtime/Scripts/Internal/Players/PlatformMediaPlayer.cs or Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs

When I use the Media Player Video API, playback works and does not crash. This is still OpenGLES3. Thank you for the suggestion, I'm not sure how I didn't try that one! image

When I switch to Vulkan, the overall app performance is very bad and we run out of memory and the app crashes. This seems separate from AVPro, but do you or anyone on this thread have any suggestions to build for Vulkan?

Chris-RH commented 5 months ago

Just rereading this thread.
You can't use OES rendering with Vulkan, it is OpenGLES and Exoplayer only. Probably not relevant, because you said it crashed in BGRA as well.

Having a bit of a google, there do seem to be quite a few threads popping up regarding Vulkan and memory issues. Are you using SRP, URP or HDRP?

It will be interesting to see if there is any improvement after updating to Meta's v64

Last8Exile commented 5 months ago

I think issue with AVPro calls void androidx.media3.exoplayer.SeekParameters with invalid arguments. MediaPlayer.Control.SeekFast() on C# side passes double.PositiveInfinity and double.NegativeInfinity to SeekWithTolerance. Seems they are valid with exoplayer and invalid with media3. And unhandled exception kills application.

Anton111111 commented 5 months ago

I think issue with AVPro calls void androidx.media3.exoplayer.SeekParameters with invalid arguments.

In my case app crash immediatly on start app. But on the first scene i don't have AvPro at all.

eeease commented 5 months ago

Just rereading this thread. You can't use OES rendering with Vulkan, it is OpenGLES and Exoplayer only. Probably not relevant, because you said it crashed in BGRA as well.

Having a bit of a google, there do seem to be quite a few threads popping up regarding Vulkan and memory issues. Are you using SRP, URP or HDRP?

It will be interesting to see if there is any improvement after updating to Meta's v64

Thanks for the info. We are using URP at the moment. No discrete plans to change to HDRP, though it's not out of the realm of possibility.

Anton111111 commented 5 months ago

It will be interesting to see if there is any improvement after updating to Meta's v64

In my case without changes after upgrade to v64

Chris-RH commented 5 months ago

@eeease Does this still occur when using SRP? What URP setting is it? High Fidelity/Balanced/Performant? Have you tried the other ones?

eeease commented 5 months ago

@eeease Does this still occur when using SRP? What URP setting is it? High Fidelity/Balanced/Performant? Have you tried the other ones?

I'm not really sure how to answer those questions. We are using a Universal Render Pipeline asset that is assigned to Graphics > Scriptable Render Pipeline Settings. Does that mean we're using SRP, but with a URP Asset?

I don't see High Fidelity/Balanced/Performant as options anywhere.

I'm attaching screenshots of our Graphics Assets, including the Inspector.

URP1 URP3 URP2

eeease commented 5 months ago

It will be interesting to see if there is any improvement after updating to Meta's v64

In my case without changes after upgrade to v64

Same.

Last8Exile commented 5 months ago

@Chris-RH I found error leading to crash in SeekFast method:

Assets\Plugins\AVProVideo\Runtime\Scripts\Internal\Players\PlatformMediaPlayer.cs SeekFast(double toTime) calls SeekWithTolerance(toTime, double.PositiveInfinity, double.PositiveInfinity);

This values passed as double through: PlatformMediaPlayer+Native.AVPPlayerSeek(_player, toTime, toleranceBefore, toleranceAfter); and com.renderheads.AVPro.Video.Manager.Player_Seek(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3)

all double parameters multipied by 1000.0D then casted to long long l2 = (long)(paramDouble2 * 1000.0D); l2 becomes 9223372036854775807

Then they passed to: com.renderheads.AVPro.Video.Player_ExoPlayer._seekWithTolerances(long paramLong1, long paramLong2, long paramLong3)

Then another multiplication by 1000L long l2 = paramLong2 * 1000L; l2 becomes -1000

And finally they passed to new (long toleranceBeforeUs, long toleranceAfterUs). Both arguments must be positive. So thats why we get java.lang.IllegalArgumentException.

In AVPro v2 different implementaion is used: com.renderheads.AVPro.Video.Player_ExoPlayer._seekFast(long paramLong)

This is happened then AppleMediaPlayer.cs merged with AndroidMediaPlayer.cs into PlatformMediaPlayer.cs and both start using implementation from AppleMediaPlayer.

Chris-RH commented 5 months ago

@Last8Exile thanks, I have passed that information on to the dev team

@eeease They are in the Quality settings section. I think it defaults to High Fidelity. I don't have a Quest 2 to hand, so I'm interested to know if changing the settings helps at all.

quality

eeease commented 5 months ago

@Chris-RH We set Android to default to Very Low. We added the Quest - Android setting but I don't think we're using it to build. image

Chris-RH commented 5 months ago

Ahh, ok, thanks :)

I'll update you when the dev team has managed to look into the Seek issue.

SlimsDonxi commented 5 months ago

I think issue with AVPro calls void androidx.media3.exoplayer.SeekParameters with invalid arguments.

In my case app crash immediatly on start app. But on the first scene I don't have AvPro at all.

Same here, brand new project, just imported the package !

App crashes instantly on press, before the Unity logo Abort message: 'JNI DETECTED ERROR IN APPLICATION: mid == null in call to CallStaticObjectMethodV'

All arm64 plugins are correctly set to Android CPU: ARM64 Clearly the libAVProVideo2Native.so is causing all the issues, but I got no clue how to go from here !

WikkidEdd commented 4 months ago

We're having the same issue as the OP i.e the Seek causing a crash due to invalid arguments.

@Last8Exile's summary of the problem is spot on. You can work around the issue by changing this line SeekWithTolerance(toTime, double.PositiveInfinity, double.PositiveInfinity); in Assets\Plugins\AVProVideo\Runtime\Scripts\Internal\Players\PlatformMediaPlayer.cs to something more reasonable that won't trigger the overflow.

We've set it to SeekWithTolerance(toTime, 9999, 9999);

Ste-RH commented 3 months ago

RE Seek issue. You are 100% correct. Thanks for digging into it. This will be fixed in v3.0.2 (penciled for release this week)

Chris-RH commented 3 months ago

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