General slowness since incorporating the kodi driver

More
2 years 1 month ago #2670 by bowlingbeeg
I'm not sure what's going on but since I incorporated the kodi driver for one of my sources it seems like there is general slowness/unresponsiveness in the remote/myServer.  For example I see this in the logs:

08/06/2024 21:11:49.11 · DEBUG · Server.doCommand - AV|64~SelectDevice from myremote 
08/06/2024 21:12:04.12 · DEBUG · Server.doCommand - Setvariable|theater_kodi_id~64 from myremote 

Every other device is instantaneous.  I'm not sure if it has to do with the fact that the kodi driver is pinging the device constantly(I see tons of traces when I turn on verbose logging) or if something else is going on.  Or perhaps it has nothing to do with the Kodi driver but it's the only change I've made lately and I noticed it right after I incorporated so it seems like the most likely candidate.  I guess I could try and disable it for a while to see if things go back to normal but then I can't use my shiny new device :)  

Please Log in to join the conversation.

More
2 years 1 month ago - 2 years 1 month ago #2671 by bowlingbeeg
Looks like maybe the reason for the long delay in selecting the device is because the kodi box is powered off. If I turn it on then that step goes really quick, just like the rest of the equipment.  The order of events is that you activate the room which selects all of the devices in the room before they get powered on so I'm not sure why the "ActivateRoomDevices" command should have to communicate with the kodi instance.  Is this something that could be changed?
Last edit: 2 years 1 month ago by bowlingbeeg.

Please Log in to join the conversation.

More
2 years 1 month ago #2679 by davep
The Kodi driver will normally poll for now playing info as long as it has a connection to the player. If the connection drops it should stop polling. I'm testing Kodi running on a Shield and it appears to work as described. If you turn on verbose logging in the Kodi driver and you turn off your Kodi player are you still seeing it try to poll and log timeouts? I'll also investigate that more here.

Please Log in to join the conversation.

More
2 years 1 month ago #2680 by bowlingbeeg
So there are a couple of issues I've encountered and I want to try and spell them out clearly so we can address them.

1) During the startup sequence the activate-room macro is called but the Kodi box is off at this point. I see a large delay in the ActivateRoomDevices flow where it's doing the SelectDevice command on the Kodi box. Here are the traces from that

11/06/2024 15:50:34.50 · DEBUG · Server.doCommand - AV|64~SelectDevice from mymoonlightphones-fx-yztb
11/06/2024 15:50:34.50 · DEBUG · Kodi.doCommand - Cmd=[64~SelectDevice] Client=[mymoonlightphones-fx-yztb]
11/06/2024 15:50:52.50 · DEBUG · Kodi.Connect - CoreELEC disconnected
11/06/2024 15:50:52.50 · DEBUG · Server.doCommand - Setvariable|theater_kodi_id~64 from mymoonlightphones-fx-yztb

As you can see there's an 18 second delay. This is the slowness I have been seeing. In my flows I'm always selecting the room whenever I switch sources so the SelectDevice command is always called on the Kodi box but it's always off at the time that call is made. So anytime I switch sources there is a log delay. Now I don't have to do that since I'm only using one room right now but I did it this way so if I use this in other rooms the source I'm switching to will dictate which active-room flow to call and then the user doesn't need to know how to do that.

2) After the startup sequence has completed the first command to the Kodi box always fails because the connection hasn't been established. I'm guessing that's because the SelectDevice ran while the Kodi box was powered off. It does establish the connection after that failure and then commands work as normal. I also see the polling start up. Here are some logs from that

11/06/2024 16:06:23.06 · DEBUG · Server.doCommand - AV|{{theater_kodi_id}}~Select from mymoonlightphones-fx-yztb
11/06/2024 16:06:23.06 · DEBUG · Server.doCommand - AV|64~Select
11/06/2024 16:06:23.06 · DEBUG · Kodi.doCommand - Cmd=[64~Select] Client=[mymoonlightphones-fx-yztb]
11/06/2024 16:06:23.06 · ERROR · Kodi.SendCommand - Cannot send command. Socket is Closed
11/06/2024 16:06:23.06 · DEBUG · Kodi.Connect - CoreELEC connected
11/06/2024 16:06:24.06 · DEBUG · Kodi.TX:CoreELEC - {"jsonrpc":"2.0","id":"Application.GetProperties","method":"Application.GetProperties","params":{"properties":["volume","muted"]} ,"id":"Application.GetProperties"}
11/06/2024 16:06:24.06 · DEBUG · Kodi.TX:CoreELEC - {"jsonrpc":"2.0","id":"Player.GetActivePlayers","method":"Player.GetActivePlayers","id":"Player.GetActivePlayers"}

And to answer your question about the polling, yes it does stop after the connection drops.

Please Log in to join the conversation.

More
2 years 1 month ago #2698 by davep
You're assumptions are all correct. I've modified the driver so that connections are attempted asynchronously. They should not cause any slowdowns now.

Additionally you may want to modify the activation macro to turn on your kodi player before trying to run the SelectDevice command. In my setup I have to make sure Kodi is running on the Shield before I do the SelectDevice. My macro looks like this:

// Tell the driver what device is active!
//!
// If you are running an app on an AppleTV, FireTV, Shield or similar device it may be necessary to launch it first!
// Uncomment and edit the next command if this is required!
// AV|<DEVICEID>~Launch~<APPNAME>!
AV|31~Launch~Kodi!
//!
AV|{{{{activeroom_{{clientname}}}}_kodi_id}}~SelectDevice!
//!

The driver will now also buffer the last command sent to it. In the event that the driver is not connected to the player when when the command is sent it will try to connect to the player and upon connecting the buffered command will be sent.

Give the new driver a try and see if it works better.

Please Log in to join the conversation.

More
2 years 1 month ago #2699 by bowlingbeeg
Thanks Dave, I'll give the new driver a try. While I was waiting for you to get a chance to look into these issues I did move the SelectDevice command in the activation macro to after I powered on the device like you suggested.

Please Log in to join the conversation.

Time to create page: 0.180 seconds