Baseflow / ExoPlayerXamarin

Xamarin bindings library for the Google ExoPlayer library

Home Page:https://baseflow.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

System.TypeLoadException when using PlayerNotificationManager.IMediaDescriptionAdapter

segfaults-behind-you opened this issue Β· comments

πŸ› Bug Report

Application crashes when class that implements interface:
PlayerNotificationManager.IMediaDescriptionAdapter
is being instantiated.

Exception that is thrown:
Could not load type 'Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.IMediaDescriptionAdapter' from assembly 'ExoPlayer.UI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

Other interfaces provided by PlayerNotificationManager present the same behaviour.

Possibly some other nested types may also cause the app to crash when implemented or referenced, might be worth checking.

Expected behavior

It would be cool, if it wouldn't crash. :~D

Reproduction steps

Try to run the attached project on a physical android device or on an emulator.

  1. Build and Run the application.
  2. During deployment to the device exception should be thrown.

ExoTest.zip

Configuration

Android 9
Version:
2.11.4
Platform:

  • πŸ“± iOS
  • πŸ€– Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • πŸ“Ί tvOS
  • πŸ’ Xamarin.Forms
commented

I can definitively confirm that I'm getting the same Exception thrown on the latest version of Exoplayer with Android 10 as well.. Would be nice indeed if it didn't crash but oh well.

commented

Still seems to be an issue on 2.11.6 combined with the latest version of XamarinMediaManager (0.9.9)

@martijn00 Could you have a look at this?

commented

Could this be re-opened? I'm still getting the same exception with the sample below (Which is based off of the sample with the original issue's sample, just updated to 2.11.6 and c#8 enabled)

ExoTest.zip

@jessewtf
Same here.
These are the settings, that I've set. I guess this should do the trick, but doesn't. Also AndroidX seems to be turned on - screenshot which shows that MainActivity inherits from AndroidX.[...].

This is a clean Forms project, only exoplayer was added.

Screenshot 2020-07-02 at 23 07 34

Screenshot 2020-07-02 at 23 08 21

Screenshot 2020-07-02 at 23 09 18

Screenshot 2020-07-02 at 23 10 50

Screenshot 2020-07-02 at 23 23 11

@martijn00 Would you be able to provide some pointers, please? Am I missing something?

If you want me to look into this you can make a PR or send me an email for commercial support.

Hi @martijn00 . I'm a bit confused about your approach.
Maybe this and other interfaces that can't be instantiated are part of commercial support. In such case, you should state it clearly in README so that everyone can make conscious decision if want to use your software or not.
Apart form that if you can't provide working instructions how to run your software, why would I pay you for commercial support? This doesn't add up for me.
Either way everyone would want to know if this is paid feature or you have no idea how to fix it because it simply works for you.

I've looked some more into this. It seems that (at least on my mac) there is some issue during type loading.

In RuntimeTypeHandle.cs line 342 (This file comes from mono), there is:

var t = internal_from_name (typeName, ref stackMark, null, throwOnError, ignoreCase, false);
if (throwOnError && t == null)
	throw new TypeLoadException ("Error loading '" + typeName + "'");

So in my case on macOS, some interfaces that are nested in PlayerNotificationManager have typeName that follows the following convention:
Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager/NESTED_INTERFACE, ExoPlayer.UI
for example:
Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager/ICustomActionReceiverInvoker, ExoPlayer.UI
but for PlayerNotificationManager.IMediaDescriptionAdapter it looks like this:
Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.IMediaDescriptionAdapter, ExoPlayer.UI
and this part causes the exception to be thrown.

After changing it to:
Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager/IMediaDescriptionAdapter, ExoPlayer.UI
during debug, application runs as expected and notification is shown.

I guess this can be changed in ExoPlayer.UI/Transforms/Metadata.xml but I am not really sure how to do it right now.
I could try to create a PR with a fix, but I would have to read some more about java bindings.

Would you be able to look into this? @martijn00

Also this seems to be the same thing happening, but to the other interface:
#108

EDIT: 14.07.2020
After further investigation it seems that this is exactly the issue we are facing:
xamarin/java.interop#661

I've created Exoplayer.UI nuget package locally with <_EnableInterfaceMembers>true</_EnableInterfaceMembers>
removed - then the package doesn't contain methods that have default implementations in java - for our case, this is enough for now.

I've tried to create a binding on macOS with VS updated from the current preview channel, but the fix does not seem to be there yet. Because the registration still has dot "." instead of slash "/".

	[Register ("getCurrentSubText", "(Lcom/google/android/exoplayer2/Player;)Ljava/lang/CharSequence;", "GetGetCurrentSubText_Lcom_google_android_exoplayer2_Player_Handler:Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.IMediaDescriptionAdapter, ExoPlayer.UI")]
	unsafe ICharSequence GetCurrentSubTextFormatted (IPlayer player);

I guess we'll have to wait for the binding generator to work properly.