lyarenei / jellyfin-plugin-listenbrainz

ListenBrainz plugin for Jellyfin.
MIT License
78 stars 3 forks source link

[Bug]: Plugin does not work after update to 3.4.0.0 from 3.3.2.0 #85

Closed AnotherStranger closed 9 months ago

AnotherStranger commented 9 months ago

Bug description

I tried to install the plugin for the first time today. However, the installation did not work. After downgrading the plugin to Version 3.3.2.0 it did work.

It seems like the MetaBrainz.MusicBrainz.dll cannot be found.

Jellyfin Version: 10.8.13 Broken Version: 3.4.0.0 Working Version: 3.3.2.0

Steps to reproduce

  1. Create a new Jellyfin Server using the official Docker image.
  2. Install the plugin using the Repository method
  3. Restart jellyfin
  4. Observe that the plugin won't start.

Expected behavior

The plugin should start correctly.

Actual behavior

The plugin does not start. It goes into a malfunctioning state. grafik

Jellyfin logs

[2024-02-19 07:26:38.989 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "MetaBrainz.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021" from "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.Common.dll"
[2024-02-19 07:26:39.202 +00:00] [ERR] [1] Emby.Server.Implementations.Plugins.PluginManager: Failed to load assembly "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.MusicBrainz.dll". This error occurs when a plugin references an incompatible version of one of the shared libraries. Disabling plugin.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.

Plugin version

3.4.0

Jellyfin Version

10.8.13

Additional info

Thank you for your Help! Please let me know if I can assist you in any way.

lyarenei commented 9 months ago

Edit: Well, now that I am looking at it... Are you compiling the plugin yourself or are you installing it from the repository? Because I have inaccurate compilation steps and I never noticed it, the plugin must be compiled targeting .NET 6, while .NET 7 SDK must be installed.


Hmm, this is weird. I just tried clean installation of the plugin on my server and the plugin works without any issues.

While I understand the message and what to usually do, I honestly don't know what the problem could be in your case. The plugin is compiled with .NET6.0, the same as JF 10.8.13, so the dependency DLLs should be compatible with it.

I also have JF deployed in the official docker image (although through truecharts) => we should have nearly the same environment, so that should not be it either.

Here are some things (I can think of) that you can try out. And of course if you did not try them already. Just to be sure, always do the clean installation (below).


How to do clean installation of the plugin:

  1. Uninstall the plugin from admin UI
  2. Go to plugin directory ($CONFIG_DIR/plugins)
  3. Remove all ListenBrainz_* folders, if any
  4. Restart Jellyfin
  5. Install plugin again (and restart Jellyfin)
amarevite commented 9 months ago

Using lscr.io/linuxserver/jellyfin:latest, I have the same problem and get the same error. When I realized the plugin wasn't sending listens, I tried checking the plugin settings but it was malfunctioned.

  1. I stopped Jellyfin with docker stop jellyfin
  2. Removed all plugins/ListenBrains_* folders
  3. Started Jellyfin with docker start jellyfin
  4. Installed the plugin from the catalog tab
  5. Restarted Jellyfin with docker restart jellyfin

But the plugin is still malfunctioned.

Then I installed 3.3.2.0 from the catalog, uninstalled 3.4.0.0, and ran docker restart jellyfin, which led to this on the main plugins page:

image

The plugin works while in this state (still running 3.3.2.0 if I understand correctly), but upon restarting I am back to the single 3.4.0.0 plugin which is still malfunctioned.

lyarenei commented 9 months ago

Okay, so this will probably a bigger issue. I have no idea what's going on and worse, I can't reproduce the issue. Or at least right now.

For now, I'll just remove the release from repository and I'll try to look into it later (it's getting too late here and I gotta get some sleep :slightly_smiling_face:).


So whoever is reading this issue and has the same problem, please uninstall the 3.4.0.0 version and reinstall version 3.3.2.0, which seems to work (it should now show as latest version in the repository). Thank you and sorry for the inconvenience.

lyarenei commented 9 months ago

I tried reproducing the issue with docker instance on my PC rather than on server - although with manual installation instead of from repository as it's not available now (I just got the zip from repo, so the files are are the same). And I'm still not able to reproduce the issue. The plugin loads just fine.

[2024-02-20 14:11:59.045 +00:00] [INF] [1] Emby.Server.Implementations.AppBase.BaseConfigurationManager: Setting cache path: "/cache"
[2024-02-20 14:11:59.095 +00:00] [INF] [1] Emby.Server.Implementations.ApplicationHost: Loading assemblies
[2024-02-20 14:11:59.110 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz.Api, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.Api.dll"
[2024-02-20 14:11:59.115 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.dll"
[2024-02-20 14:11:59.116 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz.Http, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.Http.dll"
[2024-02-20 14:11:59.117 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021" from "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.Common.Json.dll"
[2024-02-20 14:11:59.127 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "MetaBrainz.MusicBrainz, Version=6.1.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021" from "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.MusicBrainz.dll"
[2024-02-20 14:11:59.127 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "MetaBrainz.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021" from "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.Common.dll"
...
[2024-02-20 14:12:01.079 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded plugin: "ListenBrainz" "3.4.0.0"
[2024-02-20 14:12:01.080 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded plugin: "TMDb" "10.8.13.0"
[2024-02-20 14:12:01.080 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded plugin: "Studio Images" "10.8.13.0"
[2024-02-20 14:12:01.080 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded plugin: "OMDb" "10.8.13.0"
[2024-02-20 14:12:01.080 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded plugin: "MusicBrainz" "10.8.13.0"
[2024-02-20 14:12:01.081 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded plugin: "AudioDB" "10.8.13.0"
[2024-02-20 14:12:01.142 +00:00] [INF] [1] Main: Kestrel listening on "Any IP4 Address"

@AnotherStranger @amarevite According to the Jellyfin code, there should be a stacktrace logged as well. Can you please post more complete log? That might tell us some details. Thank you.

AnotherStranger commented 9 months ago

Hey @lyarenei, I just got home from work. I will see what I can provide!

Update: I spun up a shell in my docker container. The files in question do exist. I will try to update to 3.4.0 now and will try to paste a full log here.

Update update:


[2024-02-20 17:56:36.660 +00:00] [ERR] [1] Emby.Server.Implementations.ApplicationHost: Error creating "Jellyfin.Plugin.ListenBrainz.Tasks.LovedTracksSyncTask"
System.TypeInitializationException: The type initializer for 'MetaBrainz.MusicBrainz.Query' threw an exception.
 ---> System.IO.FileLoadException: Could not load file or assembly 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'. Could not find or load a specific file. (0x80131621)
File name: 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'
 ---> System.IO.FileLoadException: Could not load file or assembly 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
   at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)
   at System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(RuntimeAssembly assembly, String assemblyFullName)
   --- End of inner exception stack trace ---
   at MetaBrainz.MusicBrainz.Query.get_DefaultPort()
   at MetaBrainz.MusicBrainz.Query..ctor()
   at MetaBrainz.MusicBrainz.Query..ctor(String application, String version, String contact)
   at Jellyfin.Plugin.ListenBrainz.Clients.MetadataClient..ctor(String clientName, String version, String contactUrl)
   at Jellyfin.Plugin.ListenBrainz.Utils.ClientUtils.GetMusicBrainzClient(ILogger logger, IHttpClientFactory clientFactory)
   at Jellyfin.Plugin.ListenBrainz.Tasks.LovedTracksSyncTask..ctor(ILoggerFactory loggerFactory, IHttpClientFactory clientFactory, ILibraryManager libraryManager, IUserManager userManager, IUserDataRepository dataRepository, IUserDataManager dataManager)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Emby.Server.Implementations.ApplicationHost.CreateInstanceSafe(Type type)
[2024-02-20 17:56:36.664 +00:00] [ERR] [1] Emby.Server.Implementations.ApplicationHost: Error creating "Jellyfin.Plugin.ListenBrainz.Tasks.ResubmitListensTask"
Jellyfin.Plugin.ListenBrainz.Exceptions.PluginException: Saving cache failed
 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path '/_3.4.0.0/cache.json'.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.IO.File.Create(String path)
   at Jellyfin.Plugin.ListenBrainz.Managers.ListensCacheManager.Save()
   --- End of inner exception stack trace ---
   at Jellyfin.Plugin.ListenBrainz.Managers.ListensCacheManager.Save()
   at Jellyfin.Plugin.ListenBrainz.Managers.ListensCacheManager.get_Instance()
   at Jellyfin.Plugin.ListenBrainz.Tasks.ResubmitListensTask..ctor(ILoggerFactory loggerFactory, IHttpClientFactory clientFactory, IUserManager userManager, ILibraryManager libraryManager)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Emby.Server.Implementations.ApplicationHost.CreateInstanceSafe(Type type)
[2024-02-20 17:56:36.665 +00:00] [INF] [1] Jellyfin.Plugin.PlaybackReporting.TaskCleanDb: TaskCleanDb Loaded
[2024-02-20 17:56:36.668 +00:00] [INF] [1] Jellyfin.Plugin.PlaybackReporting.TaskRunBackup: TaskRunBackup Loaded
[2024-02-20 17:56:36.698 +00:00] [INF] [1] Emby.Server.Implementations.ScheduledTasks.TaskManager: Daily trigger for "Playback Reporting Trim Db" set to fire at 2024-02-21 00:00:00.000 +00:00, which is 06:03:23.3014621 from now.
[2024-02-20 17:56:36.727 +00:00] [INF] [1] Emby.Server.Implementations.ScheduledTasks.TaskManager: Daily trigger for "Extrahiere Kapitel-Bilder" set to fire at 2024-02-21 02:00:00.000 +00:00, which is 08:03:23.2721012 from now.
[2024-02-20 17:56:36.837 +00:00] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: Found ffmpeg version "5.1.4"
[2024-02-20 17:56:36.924 +00:00] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: Available "decoders": ["libdav1d", "av1", "av1_cuvid", "av1_qsv", "h264", "h264_qsv", "h264_cuvid", "hevc", "hevc_qsv", "hevc_cuvid", "mpeg2video", "mpeg2_qsv", "mpeg2_cuvid", "mpeg4", "mpeg4_cuvid", "msmpeg4", "vc1_qsv", "vc1_cuvid", "vp8", "libvpx", "vp8_cuvid", "vp8_qsv", "vp9", "libvpx-vp9", "vp9_cuvid", "vp9_qsv", "aac", "ac3", "dca", "flac", "mp3", "truehd"]
[2024-02-20 17:56:36.986 +00:00] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: Available "encoders": ["libx264", "h264_amf", "h264_nvenc", "h264_qsv", "h264_v4l2m2m", "h264_vaapi", "libx265", "hevc_amf", "hevc_nvenc", "hevc_qsv", "hevc_vaapi", "mpeg4", "msmpeg4", "libvpx", "libvpx-vp9", "aac", "libfdk_aac", "ac3", "dca", "flac", "libmp3lame", "libopus", "truehd", "libvorbis", "srt"]
[2024-02-20 17:56:37.045 +00:00] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: Available filters: ["deinterlace_qsv", "deinterlace_vaapi", "hwupload_cuda", "hwupload_vaapi", "overlay_opencl", "overlay_qsv", "overlay_vaapi", "overlay_cuda", "procamp_vaapi", "scale_cuda", "scale_opencl", "scale_qsv", "scale_vaapi", "tonemap_cuda", "tonemap_opencl", "tonemap_vaapi", "vpp_qsv", "yadif_cuda", "zscale", "alphasrc"]
[2024-02-20 17:56:37.392 +00:00] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: Available hwaccel types: ["cuda", "vaapi", "qsv", "drm", "opencl", "vulkan"]
[2024-02-20 17:56:37.858 +00:00] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: VAAPI device "/dev/dri/renderD128" is Intel GPU (iHD)
[2024-02-20 17:56:37.858 +00:00] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: FFmpeg: "/usr/lib/jellyfin-ffmpeg/ffmpeg"
[2024-02-20 17:56:37.860 +00:00] [INF] [1] Emby.Server.Implementations.ApplicationHost: ServerId: "6307a9c961b24284b39585dabce3321d"
[2024-02-20 17:56:37.861 +00:00] [ERR] [1] Emby.Server.Implementations.ApplicationHost: Error creating "Jellyfin.Plugin.ListenBrainz.EntryPoint"
System.TypeInitializationException: The type initializer for 'MetaBrainz.MusicBrainz.Query' threw an exception.
 ---> System.IO.FileLoadException: Could not load file or assembly 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'. Could not find or load a specific file. (0x80131621)
File name: 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'
 ---> System.IO.FileLoadException: Could not load file or assembly 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
   at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)
   at System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(RuntimeAssembly assembly, String assemblyFullName)
   --- End of inner exception stack trace ---
   at MetaBrainz.MusicBrainz.Query.get_DefaultPort()
   at MetaBrainz.MusicBrainz.Query..ctor()
   at MetaBrainz.MusicBrainz.Query..ctor(String application, String version, String contact)
   at Jellyfin.Plugin.ListenBrainz.Clients.MetadataClient..ctor(String clientName, String version, String contactUrl)
   at Jellyfin.Plugin.ListenBrainz.Utils.ClientUtils.GetMusicBrainzClient(ILogger logger, IHttpClientFactory clientFactory)
   at Jellyfin.Plugin.ListenBrainz.EntryPoint..ctor(ISessionManager sessionManager, ILoggerFactory loggerFactory, IHttpClientFactory clientFactory, IUserDataManager userDataManager, ILibraryManager libraryManager, IUserManager userManager)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Emby.Server.Implementations.ApplicationHost.CreateInstanceSafe(Type type)
   ``
lyarenei commented 9 months ago

@AnotherStranger Hi, thanks for the log:

System.IO.DirectoryNotFoundException: Could not find a part of the path '/_3.4.0.0/cache.json'

For manual upgrade, you need to name the plugin folder ListenBrainz_3.4.0.0. Sorry, I forgot to mention that.

Alternatively, if you prefer the repo way, you can switch to my development repo. The repository address is https://repo.xkrivo.net/jellyfin-dev/manifest.json

AnotherStranger commented 9 months ago

@lyarenei Hey I installed the plugin using the dev repo. However the DirectoryFoundException persists. Here I included the output of ls:

/config/plugins$ ls
 configurations               Fanart_10.0.0.0        ListenBrainz_3.4.0.0      'Playback Reporting_13.0.0.0'  'Subtitle Extract_2.0.0.0'  'TMDb Box Sets_10.0.0.0'
'Cover Art Archive_7.0.0.0'   ListenBrainz_3.3.2.0  'Open Subtitles_19.0.0.0'   Reports_15.0.0.0               TheTVDB_10.0.0.0            TVmaze_10.0.0.0
lyarenei commented 9 months ago

@AnotherStranger Huh.. So if you upgrade from previously functioning plugin version, you end up with directory not found and if you install 3.4 right away, you get the DLL error, correct? Is that a consistent behavior? Maybe something broke with the manual upgrade, I don't know.

Can you please try again? Delete all plugin versions, restart Jellyfin, and install version 3.4.0.1 I recently pushed (in dev repo). I tried strictly locking down the .NET version to 6.0 and upgraded the build action for that one. I really don't think it'll help, but let's see.

Thank you.

AnotherStranger commented 9 months ago

Hey, after trying to reproduce the issue on another machine I couldn't. Even though I used the same docker-compose file. I try to look for differences

AnotherStranger commented 9 months ago

@lyarenei Okay I think I found something. I deactivated every other plugin and now it works. Now I just have to find out what plugin breaks yours!

AnotherStranger commented 9 months ago

@lyarenei I found the plugin breaking ListenBrainz! Its "Cover Art Archive": grafik

If i disable this plugin everything works. Can you reproduce the issue if you install this plugin to your test environment?

Maybe your dependencies do clash? Have a look:

/config/plugins$ ls Cover\ Art\ Archive_7.0.0.0/
Jellyfin.Plugin.CoverArtArchive.dll  jellyfin-plugin-coverartarchive.png  MetaBrainz.Common.Json.dll  MetaBrainz.MusicBrainz.CoverArt.dll  meta.json
amarevite commented 9 months ago

I can confirm in my case as well that disabling Cover Art Archive resolves the problem for versions 3.4.0.0 and 3.4.0.1 from the dev repo.

lyarenei commented 9 months ago

@AnotherStranger Good find, indeed, after installing CoverArt, the plugin breaks

[21:06:01] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: FFmpeg: /usr/lib/jellyfin-ffmpeg/ffmpeg
[21:06:01] [INF] [1] Emby.Server.Implementations.ApplicationHost: ServerId: 572f60ba183543d68a94abce2e79b090
[21:06:01] [ERR] [1] Emby.Server.Implementations.ApplicationHost: Error creating Jellyfin.Plugin.ListenBrainz.EntryPoint
System.TypeInitializationException: The type initializer for 'MetaBrainz.MusicBrainz.Query' threw an exception.
 ---> System.IO.FileLoadException: Could not load file or assembly 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'. Could not find or load a specific file. (0x80131621)
File name: 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'
 ---> System.IO.FileLoadException: Could not load file or assembly 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'.

ListenBrainz is built with 6.0, however CoverArt with 5.1. And because CoverArt loaded first, the older version was used by the server and ListenBrainz fails:

[2024-02-20 21:05:57.994 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.CoverArtArchive, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/Cover Art Archive_7.0.0.0/Jellyfin.Plugin.CoverArtArchive.dll"
[2024-02-20 21:05:57.995 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz.Api, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.Api.dll"
[2024-02-20 21:05:57.998 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.dll"
[2024-02-20 21:05:57.998 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz.Http, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.Http.dll"
[2024-02-20 21:05:57.998 +00:00] [ERR] [1] Emby.Server.Implementations.Plugins.PluginManager: Failed to load assembly "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.Common.Json.dll". Disabling plugin.
System.IO.FileLoadException: Assembly with same name is already loaded
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Emby.Server.Implementations.Plugins.PluginManager.LoadAssemblies()+MoveNext()
[2024-02-20 21:05:58.072 +00:00] [ERR] [1] Emby.Server.Implementations.Plugins.PluginManager: Failed to load assembly "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.MusicBrainz.dll". This error occurs when a plugin references an incompatible version of one of the shared libraries. Disabling plugin.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.

Sadly, this means that plugins do not have isolated dependencies and instead all dependencies are shared globally. This is definitely a problem. However, I am not sure if this is a dotnet feature or a Jellyfin issue. I'll try to raise an issue there.

Other than that, the fix is clear, revert #78, but I'll need to implement rate limit handling there first.

Thank you for the report and info @AnotherStranger @amarevite

AnotherStranger commented 9 months ago

@AnotherStranger Good find, indeed, after installing CoverArt, the plugin breaks

[21:06:01] [INF] [1] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: FFmpeg: /usr/lib/jellyfin-ffmpeg/ffmpeg
[21:06:01] [INF] [1] Emby.Server.Implementations.ApplicationHost: ServerId: 572f60ba183543d68a94abce2e79b090
[21:06:01] [ERR] [1] Emby.Server.Implementations.ApplicationHost: Error creating Jellyfin.Plugin.ListenBrainz.EntryPoint
System.TypeInitializationException: The type initializer for 'MetaBrainz.MusicBrainz.Query' threw an exception.
 ---> System.IO.FileLoadException: Could not load file or assembly 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'. Could not find or load a specific file. (0x80131621)
File name: 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'
 ---> System.IO.FileLoadException: Could not load file or assembly 'MetaBrainz.Common.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=be12cbb629c03021'.

ListenBrainz is built with 6.0, however CoverArt with 5.1. And because CoverArt loaded first, the older version was used by the server and ListenBrainz fails:

[2024-02-20 21:05:57.994 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.CoverArtArchive, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/Cover Art Archive_7.0.0.0/Jellyfin.Plugin.CoverArtArchive.dll"
[2024-02-20 21:05:57.995 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz.Api, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.Api.dll"
[2024-02-20 21:05:57.998 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.dll"
[2024-02-20 21:05:57.998 +00:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.ListenBrainz.Http, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null" from "/config/plugins/ListenBrainz_3.4.0.0/Jellyfin.Plugin.ListenBrainz.Http.dll"
[2024-02-20 21:05:57.998 +00:00] [ERR] [1] Emby.Server.Implementations.Plugins.PluginManager: Failed to load assembly "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.Common.Json.dll". Disabling plugin.
System.IO.FileLoadException: Assembly with same name is already loaded
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Emby.Server.Implementations.Plugins.PluginManager.LoadAssemblies()+MoveNext()
[2024-02-20 21:05:58.072 +00:00] [ERR] [1] Emby.Server.Implementations.Plugins.PluginManager: Failed to load assembly "/config/plugins/ListenBrainz_3.4.0.0/MetaBrainz.MusicBrainz.dll". This error occurs when a plugin references an incompatible version of one of the shared libraries. Disabling plugin.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.

Sadly, this means that plugins do not have isolated dependencies and instead all dependencies are shared globally. This is definitely a problem. However, I am not sure if this is a dotnet feature or a Jellyfin issue. I'll try to raise an issue there.

Other than that, the fix is clear, revert #78, but I'll need to implement rate limit handling there first.

Thank you for the report and info @AnotherStranger @amarevite

I have to thank you for your help and this great plugin! Maybe the Cover Art Plugin is willing to extract the clashing library into a separate plugin which you both could use as dependency? Take everything I say with a grain of salt tho. I have no experience on jellyfin development so I don't know whether this is possible.

lyarenei commented 9 months ago

Maybe the Cover Art Plugin is willing to extract the clashing library into a separate plugin which you both could use as dependency?

Not exactly a plugin but a shared library (after all, that code can be used anywhere, not just in Jellyfin plugins). And this is already the case, the JSON library is here: https://github.com/Zastai/MetaBrainz.Common.Json :slightly_smiling_face:

The problem is not that the code is not shared, but because both CoverArt and ListenBrainz basically say "I want a specific version of this library and I am not willing to compromise" (for various reasons). And so as CoverArt is loaded first by the server, it locks its dependencies and wins the race.

Now, I could recompile the plugin with downgraded version of the library and it would be probably just fine. But that would fix only this specific case. There might be very well another plugin out there which would break in exactly the same way. So it's not really a proper solution, more like a band aid.

Hope this clears it up for you a bit. :slightly_smiling_face:

lyarenei commented 9 months ago

@AnotherStranger @amarevite Just want to let you know that the issue should be fixed with version 3.4.1.0. Or at least I did not encounter any issues with CoverArt plugin.

Please do not forget to change to stable repository. Let me know if there are any issues, thank you.

amarevite commented 9 months ago

I can confirm that ListenBrainz 3.4.1.0 from the stable repo works with Cover Art Archive 7.0.0.0. I'm seeing no issues on my end. Thanks!