Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.7.3 crashes Kodi #520

Closed
venomousZealot opened this issue May 10, 2021 · 7 comments · Fixed by #521
Closed

0.7.3 crashes Kodi #520

venomousZealot opened this issue May 10, 2021 · 7 comments · Fixed by #521
Labels
bug Something isn't working

Comments

@venomousZealot
Copy link
Contributor

The new release crashes Kodi when trying to play back anything or accessing some settings. Syncing seems to work.
0.7.2 works

There isn't anything in the logs as far as I can tell, but here it is anyway:
kodi_crashlog-20210510_172111.log

I managed to do a git bisect, since I didn't know what else to do and this is the result:

979c07723101eb1215bce6de2f199cb0cc33c54c is the first bad commit
commit 979c07723101eb1215bce6de2f199cb0cc33c54c
Author: Matt <mcarlton00@gmail.com>
Date:   Sat Jun 20 18:10:36 2020 -0400

    Move websocket to a dependency

 jellyfin_kodi/jellyfin/websocket.py | 940 ------------------------------------
 jellyfin_kodi/jellyfin/ws_client.py |   4 +-
 2 files changed, 2 insertions(+), 942 deletions(-)
 delete mode 100644 jellyfin_kodi/jellyfin/websocket.py
@mcarlton00
Copy link
Member

There's something odd going on with our last few releases that I haven't been able to track down yet. Everything is working fine for me under the master profile. However, once I switch to a different profile, playback starts silently failing/crashing Kodi. And that happened on 0.7.2. Additionally, there's #510 which was 0.7.2 (and I can't replicate on the master profile), and the only changes to playback code there was your audio channel transcoding fix (which shouldn't be happening here) and adding the bitrate to the device profile (which shouldn't have broken anything). If there was anything in our code that was causing playback failure I would expect it to throw a traceback, but maybe there's something hidden or misformatted somewhere.

@venomousZealot
Copy link
Contributor Author

I had deleted my ~/.kodi folder, so it should be like a fresh install with just a master profile. After enabling the jellyfin plugin connecting and syncing was fine. First attempt to playback and crash. Choosing version 0.7.2 in Kodi and playback works again.

I don't know Python (and I kind of hate it), so I can't do more than basic logic stuff, but I will try my best to investigate this further.

@venomousZealot
Copy link
Contributor Author

Just copying websocket.py and ws_client.py over from the previous release gets it working again.

The websocket addon is there and seems to be getting "picked up". I have absolutely no clue why it crashes. I even tried older and newer releases of the websocket-client, but it made no difference.

@venomousZealot
Copy link
Contributor Author

I have tested different machines.

It is working fine in Windows.

It is not working in Ubuntu, BUT it doesn't crash. (Yay!)
Heres the debug log:
kodi.log

but allow me to emphasize this part:

ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'RuntimeError'>
Error Contents: implement_array_function method already has a docstring
Traceback (most recent call last):
  File "/home/alex/.kodi/addons/plugin.video.jellyfin/default.py", line 20, in <module>
    from entrypoint import Events  # noqa: E402
  File "/home/alex/.kodi/addons/plugin.video.jellyfin/jellyfin_kodi/entrypoint/__init__.py", line 11, in <module>
    from jellyfin import Jellyfin
  File "/home/alex/.kodi/addons/plugin.video.jellyfin/jellyfin_kodi/jellyfin/__init__.py", line 10, in <module>
    from .client import JellyfinClient
  File "/home/alex/.kodi/addons/plugin.video.jellyfin/jellyfin_kodi/jellyfin/client.py", line 11, in <module>
    from .ws_client import WSClient
  File "/home/alex/.kodi/addons/plugin.video.jellyfin/jellyfin_kodi/jellyfin/ws_client.py", line 13, in <module>
    import websocket
  File "/home/alex/.kodi/addons/script.module.websocket/lib/websocket/__init__.py", line 21, in <module>
    from ._abnf import *
  File "/home/alex/.kodi/addons/script.module.websocket/lib/websocket/_abnf.py", line 37, in <module>
    import numpy
  File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 17, in <module>
    from . import multiarray
  File "/usr/lib/python3/dist-packages/numpy/core/multiarray.py", line 14, in <module>
    from . import overrides
  File "/usr/lib/python3/dist-packages/numpy/core/overrides.py", line 16, in <module>
    add_docstring(
RuntimeError: implement_array_function method already has a docstring
-->End of Python script error report<--

@mcarlton00
Copy link
Member

That issue specifically is because you have an out of date numpy on your OS. numpy/numpy#14384

An argument could be made that Kodi shouldn't be using your system files. A further argument could be made that there's no reason for the websockets library to need it. But here we are.

The relevant code is here for the websockets library. https://github.com/pkscout/script.module.websocket/blob/57cf11a76946439920157b0cf8eb602889d6c8c0/lib/websocket/_abnf.py#L35-L49

I'll need to dig into this more later and see if I can reliably replicate it.

@mcarlton00
Copy link
Member

I've narrowed it down to being an interaction between Kodi and numpy installed to the OS. Which also explains why it's not happening on a minimal amount of devices.

On Windows, Kodi contains it's own embedded Python, so there's no environment bleed. I believe the same is true on Android based devices as well.

On Linux, Kodi uses the system Python and can pick up system libraries. This means that even though numpy isn't installed in Kodi (and isn't packaged for Kodi in anyway), if it's installed on the OS then it's possible for Kodi to import it. If I have numpy installed, then Kodi will crash on playback. If I remove it, then everything works as expected. Since it boils down to numpy installed to the OS, this is also highly unlikely to impact systems like LibreElec or OSMC, and only hits people using Kodi on their workstations. So this is either a bug in the upstream library, or maybe our ws_client.py needs to be tweaked some more to avoid whatever is happening. I hate this library.

@venomousZealot
Copy link
Contributor Author

Can confirm this fixed it. Awesome!

@mcarlton00 mcarlton00 added the bug Something isn't working label May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants