regseb / castkodi

WebExtension to cast videos and music to Kodi.
MIT License
104 stars 24 forks source link

top-right menu with red background and "Unknown error", "Failed to execute method." #34

Closed pespin closed 3 years ago

pespin commented 4 years ago

firefox version: 78.0.2 kodi version: 18.7 Git:20200528-2c5354e70a linux distro of firefox: Archlinux linux distro of kodi: raspbian castkodi: Version=5.1.0, Last Updated="July 17, 2020"

castkodi has been working fine for a while. I usually use the top-right icon which shows a menu to send links, submit control messages to Kodi, etc. Today, (probably after updating my laptop system and/or kodi's system), castkodi stopped working.

I didn't change any configuration since last time it as working (only system upgrade which may have changed castkodi, kodi or firefox version).

When I press the top-right icon, the menu appears but immediately aftewards changes to red background and shows text: "Unknown error" and "Failed to execute method.", followed by a button to go to the "configure" section.

error-menu

I attach a pcap file with firefox connecting to Kodi while I press the top-right icon and the error menu appears. websocket trace Summary:

Firefox -> Kodi: {"jsonrpc":"2.0","method":"Player.GetActivePlayers","id":1}
Firefox <- Kodi: {"id":1,"jsonrpc":"2.0","result":[]}
Firefox -> Kodi: {"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":1,"properties":["position","repeat","shuffled","speed","time","totaltime"]},"id":2}
Firefox <- Kodi: {"error":{"code":-32100,"message":"Failed to execute method."},"id":2,"jsonrpc":"2.0"}
[Firefox closes the websocket]

So it looks like castkodi is trying to access an active player which doesn't exist.

firefox-kodi-communication.pcapng.zip

pespin commented 4 years ago

BTW, I forgot to say that the Kore android app is still working fine and is able to connect and be used as a remote control.

pespin commented 4 years ago

I tested running "web-ext run" with PR #36 applied and it solves the issue.

regseb commented 4 years ago

With the same version of Kodi (OSMC running Kodi 18.7), I cannot reproduce this issue. Does this problem happen all the time?

Firefox -> Kodi: {"jsonrpc":"2.0","method":"Player.GetActivePlayers","id":1}
Firefox <- Kodi: {"id":1,"jsonrpc":"2.0","result":[]}
Firefox -> Kodi: {"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":1,"properties":["position","repeat","shuffled","speed","time","totaltime"]},"id":2}
Firefox <- Kodi: {"id":2,"jsonrpc":"2.0","result":{"position":-1,"repeat":"off","shuffled":false,"speed":0,"time":{"hours":0,"milliseconds":0,"minutes":0,"seconds":0},"totaltime":{"hours":0,"milliseconds":0,"minutes":0,"seconds":0}}}

The video player (playerid = 1) still exists, even when Player.GetActivePlayers returns an empty list. So we can get its properties.

pespin commented 4 years ago

Yes, I can reproduce it everytime, I have raspbian buster, kodi package version Version: 2:18.7-1~buster. Without this patch I cannot manage the media player through the menu until I start playing something on it by other means (for instance by using same addon by right-clicking on a link and using "Send to Kodi" or alike to send the link).

I power on the rpi with kodi, and then on clicking on the firefox plugin, through wireshark I see:

Firefox -> Kodi: {"jsonrpc":"2.0","method":"Player.GetActivePlayers","id":1}
Firefox <- Kodi: {"id":1,"jsonrpc":"2.0","result":[]}
Firefox -> Kodi: {"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":1,"properties":["position","repeat","shuffled","speed","time","totaltime"]},"id":2}
Firefox <- Kodi:  {"error":{"code":-32100,"message":"Failed to execute method."},"id":2,"jsonrpc":"2.0"}

So it looks like my kodi version has thhat somehow fixed, because in your case when you ask for players it says there's none, but nevertherless when you ask for its properties it returns them (which makes no sense because there's no such player).

regseb commented 3 years ago

I reproduced the problem with Kodi 18.7 Git:20200528-2c5354e70a under Raspbian GNU/Linux 10 (buster). The pull request https://github.com/regseb/castkodi/pull/36 has been released in version 5.6.0 (requires Firefox 82).