Kodi Community Forum
Release Artist Slideshow addon (with skin and addon integration) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: Release Artist Slideshow addon (with skin and addon integration) (/showthread.php?tid=124880)



RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-24

New Beta Available (3.0.1~beta3)
While trying to make some more changes to reduce CPU usage, I noticed that AS wasn't quitting properly on Kodi exist if running in daemon mode (i.e. in the background all the time).  That's fixed now.  I also made a couple more little tweaks to try and reduce CPU usage.

About the CPU Usage
At this point I think I've done what I can to reduce CPU usage without sacrificing the user experience. AS takes more cycles now because it has to have two threads running (one for the main program and one to control the slideshow) instead of one.  The old version didn't have to control the slideshow because it just sent the skin a folder of images and stopped caring, but the new version has to send one image at a time for it to work with the Kodi 18 artist image folder.  Basically the challenge is that the longer I sleep the threads, the longer the delay for new artist images to show up when you change artists.  I tried sleeping the threads for 5 seconds, but it was very noticeable, so I kept bumping down until I ended up with 1 second sleep cycles.  If this beta still causes too much CPU usage, I can probably bump the sleep cycles to 2 seconds, but after that it's going to look like AS can't keep up with the song changes.

About the Quit at Exit Problem
I'm documenting this here just in case some future programmer is desperately searching the internet for why their Kodi addon with threads won't quit at exit.  It turns out (whether a feature or a bug) that xbmc.Monitor().abortRequested() and (I think anyway) xbmc.Monitor().waitForAbort() will only send their response to one thread, not multiple threads.  So in the case of AS the slideshow thread was catching all the Monitor requests and terminating, but then the main thread just kept going, oblivious to Kodi's pleas for it to quit.  Kodi would eventually force quit the script, but not always.  So I ended up having the main thread monitor the state of the slideshow thread, and if the main thread saw the slideshow thread terminate, the main thread assumed it should quit too.  On of off chance the main thread catches the Monitor stuff, it'll tell the slideshow thread to close, so we're handled in both cases now.  That got the quit time for the script down to about 2 seconds, and with that Kodi was much happier when exiting.

Thanks to everyone for pointing out the issues and helping to test solutions.  As I said before, the update probably won't go into the main repo until after the new year, so use the beta repo (a few posts up) to get the beta version if you're having problems with CPU usage/heat.


RE: Artist Slideshow addon (with skin and addon integration) - Wichte - 2019-12-24

Unfortunately, for me the CPU usage problem sooner or later reappears. According to your explanation, it is rather something that the skin has to fix?

EDIT:
For me AS is completely unusable with Aeon Nox Silvio. As soon as ANY media playback starts, the cpu usage goes up and never down again. I completely disabled the addon for now.


RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-25

(2019-12-24, 09:35)Wichte Wrote: Unfortunately, for me the CPU usage problem sooner or later reappears. According to your explanation, it is rather something that the skin has to fix?

EDIT:
For me AS is completely unusable with Aeon Nox Silvio. As soon as ANY media playback starts, the cpu usage goes up and never down again. I completely disabled the addon for now.
I'd be really interested to see debug logs.  I can't figure out how AS would be spiking things when playing media, especially video, which AS would consider playing video an "idle" event.


RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-25

New Beta Available (3.0.1~beta4)
- added options to change sleep time for main and slideshow threads
- fix for property cleaning
- changed entry point default.py to be less complex

For those who would like to reduce CPU load/temperature further, I've added some options in the ADVANCED section of the settings to let you change the sleep time for both the main and slideshow threads.  While you can set the slideshow and main thread sleep times separately, AS will, from what I'm observed, behave outwardly based on the longest sleep times of the two threads.

Each thread has two different sleep times.  A sleep time and an idle sleep time.  The sleep times are the amount of time AS sleeps when you are actively displaying images.  AS wakes up to check and see if the song has changed or stopped on this cycle.  So if you increase this sleep time what you'll mostly notice is a lag between the start of a new artist's song and the start of the slideshow for the new artist.  At 2 seconds I personally can see the lag, but it's not annoying to me.  At 5 seconds I want to claw my eyes out.  The idle sleep time only applies if you are using AS with a skin that keeps AS running all the time.  When no music is playing, AS goes into a "deeper sleep" to try and reduce CPU usage further.  As you increase the default setting what you will notice is a longer period of time between the black image and when the first artist image shows up.  At 10 seconds I mostly saw less than 5 seconds before AS "woke up" because if you start a song in the middle of the sleep cycle you only have to wait until it ends, not the full 10 seconds.  I didn't try anything more than 10 seconds, but I suspect if it got towards 20 seconds I would be clawing my eyes out again.

But hey, now you all have choices about when you're going to claw your eyes out.  '-)

P.S. This is almost certainly the last update for at least a day or two unless I really want to get out of helping to fix Christmas dinner.


RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-25

New Beta (3.0.1~beta5)
- set slideshow thread to close if no music playing
- removed slideshow idle sleep time setting (no longer needed)
- changed thread sleep time settings to sliders

I lied. I had a Christmas epiphany and realized that the slideshow thread doesn't need to be running at all if music isn't playing, so this beta closes the slideshow thread when it isn't needed.  I also cleaned up some of the logic around how I'm using the Monitor class that helped at quit just a hair.  At this point with the default thread sleep settings I'm seeing between 40% and 55% usage on a single CPU when music is playing and the slideshow is running.  If the skin runs AS in daemon mode, usage drops to about 7% when music isn't playing.  At least on my OSX development machine.

I'm hoping this does it.  We'll see how testing goes for folks over the next week, and when I'm back home (right before the new year) I'll run some burn in tests on my production equipment.


RE: Artist Slideshow addon (with skin and addon integration) - Wichte - 2019-12-25

(2019-12-25, 16:23)pkscout Wrote: New Beta (3.0.1~beta5)
- set slideshow thread to close if no music playing
- removed slideshow idle sleep time setting (no longer needed)
- changed thread sleep time settings to sliders

I lied. I had a Christmas epiphany and realized that the slideshow thread doesn't need to be running at all if music isn't playing, so this beta closes the slideshow thread when it isn't needed.  I also cleaned up some of the logic around how I'm using the Monitor class that helped at quit just a hair.  At this point with the default thread sleep settings I'm seeing between 40% and 55% usage on a single CPU when music is playing and the slideshow is running.  If the skin runs AS in daemon mode, usage drops to about 7% when music isn't playing.  At least on my OSX development machine.

I'm hoping this does it.  We'll see how testing goes for folks over the next week, and when I'm back home (right before the new year) I'll run some burn in tests on my production equipment.
Ok, but now finally enjoy your holidays :-)


RE: Artist Slideshow addon (with skin and addon integration) - shedrock - 2019-12-25

I am getting the following error while playing music using the latest Beta 5 version.

https://paste.kodi.tv/ixatixelat.kodi

Regards,

Shedrock


RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-26

(2019-12-25, 18:17)shedrock Wrote: I am getting the following error while playing music using the latest Beta 5 version.

https://paste.kodi.tv/ixatixelat.kodi

Regards,

Shedrock
It would be more helpful to see a full debug log that leads up to that message.  Out of context it's basically impossible to say what triggered the error.


RE: Artist Slideshow addon (with skin and addon integration) - shedrock - 2019-12-26

(2019-12-26, 03:11)pkscout Wrote: It would be more helpful to see a full debug log that leads up to that message.  Out of context it's basically impossible to say what triggered the error. 
I think it may have stopped when I updated it on another SSD that I swapped on my KODI LE box. However, I will check it tomorrow and see if it happens again. If so, I will provide a full log.

Thank you for your assistance.

Regards,

Shedrock


RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-26

New Beta (3.0.1~beta6)
- fix for crash when trying to get last fanart number from Kodi Artist Information Folder
- fix for unicode errors causing cache trimming not to work

The problem shedrock reported might have to do with what happens when re.search gets no result, so I added some additional error trapping for that potential condition (although I still can't figure out how that particular condition can get to where the code failed, but whatever).  Hopefully that doesn't cause any unexpected behaviors somewhere else (I'm pretty sure it won't).  The other error corrected is some remaining Python 2 unicode errors that were causing the cache trimming mechanism to fail (thanks to the OSMC folks for reporting that one).  And just so nobody panics, you have to specifically enable cache trimming (i.e. deleting downloaded images), and it's only available if you're storing your images in the addon_data folder.  So if you didn't even know AS could keep your image folder down to a given size, you probably aren't using this option.


RE: Artist Slideshow addon (with skin and addon integration) - deoau - 2019-12-26

Hiya @pkscout such dedication looking at this over the holidays. Kudos to you.

I run libreelec 9.2 on an Intel NUC, pretty much standard with Aeon Nox: Silvo Skin. I have been following this after things went a bit sideways at the initial update of AS to 3.0.0 and Silvo needed to update his skin to cater for it. Initially I did not notice or could reproduce the high CPU, but as a precaution given some comments from other users that it appeared later, when I saw the 3.0.1~beta2 update, I copied that new default.py into my .kodi/addons/script.artistslideshow , and all seemed to remain OK.

Today I decided to try 3.0.1beta5, a complete update due to the new options mentioned, and noticed the high CPU straight away. This seemed odd to have introduced the problem, so I reverted. Uninstalled AS along with its options and re-installed AS 3.0.0 from the Kodi repository.

This observation might help from my fresh 3.0.0 install:
upon reboot, 100% CPU on one thread
once I start playing music with artist slideshow, CPU reduced to normal
after stopping music playback, CPU stayed normal
could not find anything unusual or indicating any issues in debug logs
repeated my copy in of default.py from 3.0.1~beta2 , CPU issue went away at reboot.


Hope this info helps. For the moment I'm leaving at beta2 which seems fine. I can re-try beta5 or anything else you think after some more feedback from others, and holidays Smile

All the best.


RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-26

(2019-12-26, 04:46)deoau Wrote: Hiya @pkscout such dedication looking at this over the holidays. Kudos to you.

I run libreelec 9.2 on an Intel NUC, pretty much standard with Aeon Nox: Silvo Skin. I have been following this after things went a bit sideways at the initial update of AS to 3.0.0 and Silvo needed to update his skin to cater for it. Initially I did not notice or could reproduce the high CPU, but as a precaution given some comments from other users that it appeared later, when I saw the 3.0.1~beta2 update, I copied that new default.py into my .kodi/addons/script.artistslideshow , and all seemed to remain OK.

Today I decided to try 3.0.1beta5, a complete update due to the new options mentioned, and noticed the high CPU straight away. This seemed odd to have introduced the problem, so I reverted. Uninstalled AS along with its options and re-installed AS 3.0.0 from the Kodi repository.

This observation might help from my fresh 3.0.0 install:
upon reboot, 100% CPU on one thread
once I start playing music with artist slideshow, CPU reduced to normal
after stopping music playback, CPU stayed normal
could not find anything unusual or indicating any issues in debug logs
repeated my copy in of default.py from 3.0.1~beta2 , CPU issue went away at reboot.


Hope this info helps. For the moment I'm leaving at beta2 which seems fine. I can re-try beta5 or anything else you think after some more feedback from others, and holidays Smile

All the best.
I found the problem causing that. New beta coming.


RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-26

New Beta (3.0.1~beta7)
- fix for slideshow thread starting too early when skin starts AS without any music playing

Available as usual from my beta repo.


RE: Artist Slideshow addon (with skin and addon integration) - GemNEye - 2019-12-27

Running newest beta, and getting similar results as the last beta.  Using LibreElec 9.2.0 with Aeon Nox:Silvo (git) on Raspberry Pi 2 (overclocked to 1000 MHz) and on Raspberry Pi 4 (overclocked to 1750 MHz).  When running without any human activity the results are similar (the rpi2 works a little harder).  Basically 1 CPU runs at about 35%-45%.  With the same passive cooling the RPI2 is running at about 41 degrees Celsius and the RPI4 is running at 51 degrees Celsius.  Both Betas run much better than the 3.0.0 AS release which was always pegged with at least 1 CPU at 100% utilization.

Thank You.


RE: Artist Slideshow addon (with skin and addon integration) - pkscout - 2019-12-27

New Beta (3.0.1~beta8)
- fixed issue where slideshow might not start when in daemon mode

I noticed today while doing some other testing that if AS is in daemon mode and you stop playing a given artist and then start playing the same artist later that the slideshow wouldn't start (it would as soon as you played a different artist).  That's fixed now.  I'm cautiously optimistic that this is the last beta version.  Available from my beta repo as usual.