Reduce default script shutdown time
#1
Increasingly we are seeing Kodi taking longer to shut down, I would like to see the default time before Kodi force closes scripts reduced to one second (down from current 5 seconds). This problem is due mainly to skin writers requiring numerous scripts (so user can't uninstall them) and poorly written script exit code. There are a number of good examples of scripts that cleanup quickly and exit, Marcel's skin helper script exits in about 1/3 of a second and Rob Webset's scripts are also good examples of scripts that just get the hell out of the way.

This change is likely to have a minimal impact on scripts as those script likely to be affected are currently being force closed anyway. Currently it only takes six slow scripts to add 30 seconds to the shutdown time of Kodi and most systems have way more than six scripts installed (most of which most users are not even aware of).

Wyrm (AppTV)
If required a FULL debug log can now be submitted from the skin in settings->skin settings->support. Or follow instructions here if you can't access skin settings.

FAQ's located at :- http://kodi.wiki/view/Add-on:AppTV
Reply
#2
(2015-10-17, 03:16)wyrm Wrote: Increasingly we are seeing Kodi taking longer to shut down, I would like to see the default time before Kodi force closes scripts reduced to one second (down from current 5 seconds).
Not going to happen. If anything this should be increased or removed. This is an extremely ugly hack that can cause all kinds of bad things to happen. It's even the cause of deadlocks in many cases. The correct solution to this problem is to write scrips that can shutdown in a more timely fashion. This is not just the fault of addons though, the core code that stops scrips is itself very slow.
Reply
#3
(2015-10-17, 12:49)takoi Wrote:
(2015-10-17, 03:16)wyrm Wrote: Increasingly we are seeing Kodi taking longer to shut down, I would like to see the default time before Kodi force closes scripts reduced to one second (down from current 5 seconds).
Not going to happen. If anything this should be increased or removed. This is an extremely ugly hack that can cause all kinds of bad things to happen. It's even the cause of deadlocks in many cases. The correct solution to this problem is to write scrips that can shutdown in a more timely fashion. This is not just the fault of addons though, the core code that stops scrips is itself very slow.
Takoi, thanks from the reply. I have to say I'm mystified by the idea of increasing or removing this limit. All it would take is one badly written script to stop Kodi from ever shutting down in that case. I don't suppose you would mind pointing me to the correct spot in the code base to have a poke around and see if anything occures to me on the problem.

Wyrm
If required a FULL debug log can now be submitted from the skin in settings->skin settings->support. Or follow instructions here if you can't access skin settings.

FAQ's located at :- http://kodi.wiki/view/Add-on:AppTV
Reply
#4
no mystery involved, 'The correct solution to this problem is to write scrips that can shutdown in a more timely fashion'. Force nuking an addon can cause even worse problems Smile
Reply
#5
(2015-10-17, 18:10)MrMC Wrote: no mystery involved, 'The correct solution to this problem is to write scrips that can shutdown in a more timely fashion'. Force nuking an addon can cause even worse problems Smile
MrMC,
Dead right correct solution is for scripts to shutdown in a timely fashion, but that is not happening. I can name at least two high profile scripts that seem to rely on Kodi nuking them to get them to stop. Point is that if the force close down time was increased it would just take longer before Kodi finally got to stop. As mentioned in my first post, most users have no idea that skins are starting up a number of script that take their sweet time wrapping things up (if at all in a number of cases). All they see is that Kodi is taking an awful long time to stop.

An ounce of prevention is worth a ton of cure in this case.

Wyrm
If required a FULL debug log can now be submitted from the skin in settings->skin settings->support. Or follow instructions here if you can't access skin settings.

FAQ's located at :- http://kodi.wiki/view/Add-on:AppTV
Reply
#6
You can see the stop code here: https://github.com/xbmc/xbmc/blob/a07c85...r.cpp#L437

The problem is that you can end up breaking things that does it right. There plenty of reasons you would want, and need to do finish something, not having it arbitrarily interrupted, before shutting down. How would you know if it's doing something or misbehaving? If it's actually doing something important it should be given time to finish, no matter how long that takes, that was my point.

A better start would be to name those scrips and improve them. If we increased the kill time to say 60 seconds, maybe people would put more effort into and don't rely on it being killed. Just a thoughSmile
Reply
#7
some python n00bs (me) could probably use some help and guidance on how to improve script shutdown times.

for instance the weather addon downloads images from openweathermap.
the site is known to be very slow at times, it can take 8 secs to get a response.
i have no idea how to kill the script while it's waiting for a response.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#8
I was planing to do a post to the mailing list these days, to at least get every addon to switch to the new type of waiting.
http://kodi.wiki/view/Service_Add-ons

That should at least help the addons, with big waits in their program loops.
Reply
#9
(2015-10-18, 22:10)takoi Wrote: A better start would be to name those scrips and improve them. If we increased the kill time to say 60 seconds, maybe people would put more effort into and don't rely on it being killed. Just a thoughSmile

Increasing the delay is a little counterintuitive, but does make a great deal of sense - it will result in those badly written addons, scripts and skins etc. standing out like a sore thumb, and they would probably never have seen the light of day in their current slow-shutdown form were it not for the 5 second nuke bailing out the developer.

Maybe we should simply get rid of the "nuke after n seconds" process completely, and the "problem" addons will soon emerge, and can be dealt with.

(2015-10-19, 01:03)Razze Wrote: I was planing to do a post to the mailing list these days, to at least get every addon to switch to the new type of waiting.
http://kodi.wiki/view/Service_Add-ons

That should at least help the addons, with big waits in their program loops.

Is it possible to review or audit add-ons in the official repo and perhaps have a requirement on using the new shutdown/wait method for new admissions, and kick those that don't pass the "fast shutdown" test? Otherwise there may be little incentive for authors to spend the time updating their addons.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#10
@takoi, Thanks for the link. Things are a little clearer now on you reasoning. The Five seconds seemed arbitrary and thus the suggestion to drop it to one, but after seeing one of the star scripts for shutdown time take over one second to shutdown in my logs I now realise that there are occasions where five might not be enough.

@Razze, Your code certainly looks the goods, maybe you should also post a sticky in the script dev forums as well as a post to the mailing list.

@ronie, milhouse, certainly did not wish for the suggestion to become a witch hunt for lazy script writers, in all likelihood they were not even aware of correct shutdown method. That and we can't lay the blame entirely at their doorstep. The on going discussions in the skin forums re too many 'required' scripts would suggest that skin writers probably could be helping out with this problem as well.

I'm really against the name and shame avenue on this as it's a multi pronged problem that needs work from all three major stake holders (script and skin writers and the devs). Probably the first step is to make the script writers aware of the issue and then have a quiet word to a number where there is a problem (service script in particular as their number have ballooned recently). When I see my 3.2GHz i5 take sometime as long as 5 minutes to shutdown the program we have an user UI issue than needs fixing. Most user would not even be aware of how many or even what scripts are running in the background, they just know it takes 'for everrrrrrr' to shutdown and that can't be good.

Wyrm (AppTV)
If required a FULL debug log can now be submitted from the skin in settings->skin settings->support. Or follow instructions here if you can't access skin settings.

FAQ's located at :- http://kodi.wiki/view/Add-on:AppTV
Reply
#11
Not so much a witch hunt, but developers need to be "incentivized" to make these changes as individually they may not consider it necessary to make any changes when 5 seconds for their script/addon alone to shutdown is not a big deal, but in a real world situation with multiple scripts/addons being used together it all adds up to ridiculously slow shutdowns. This problem is not new, yet here we are. Asking nicely will only achieve so much, and is unlikely to eradicate the problem. The official repo is (or should be) a stamp of approval that certain requirements have been met by the script, addon, skin etc. and a timely shutdown requirement could/should be added to the list.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#12
(2015-10-19, 04:04)Milhouse Wrote:
(2015-10-19, 01:03)Razze Wrote: I was planing to do a post to the mailing list these days, to at least get every addon to switch to the new type of waiting.
http://kodi.wiki/view/Service_Add-ons

That should at least help the addons, with big waits in their program loops.

Is it possible to review or audit add-ons in the official repo and perhaps have a requirement on using the new shutdown/wait method for new admissions, and kick those that don't pass the "fast shutdown" test? Otherwise there may be little incentive for authors to spend the time updating their addons.

Should be possible, but I'm not the one that can decide on this.


Btw, maybe it makes sense to add a GUI to the shutdown, showing what is shutdown at the moment?
This may be a bad idea, as it might be quiet hard, but just throwing it out there.
Reply
#13
Yes, it would be nice to know that Kodi is in progress in shutting down. So i can turn off the TV without hesitation if Kodi noticed my keypress Smile
The simple "working" spinner would already be sufficient for me.
Reply
#14
(2015-10-19, 07:27)wyrm Wrote: @ronie, milhouse, certainly did not wish for the suggestion to become a witch hunt for lazy script writers
no worries, i didn't take it that way, at all

(2015-10-19, 07:27)wyrm Wrote: I'm really against the name and shame avenue on this
if there's a flaw in my code, i would certainly appreciate it if people would notify me about it.
i can't imagine other coders would think differently about it.
it's not a name/shame thing, it's helping eachother out and improving other peoples code.

if no one points out the issues the addon dev might not be aware of, then nothing gets fixed.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#15
(2015-10-19, 20:58)ronie Wrote:
(2015-10-19, 07:27)wyrm Wrote: I'm really against the name and shame avenue on this
if there's a flaw in my code, i would certainly appreciate it if people would notify me about it.
i can't imagine other coders would think differently about it.
it's not a name/shame thing, it's helping eachother out and improving other peoples code.

if no one points out the issues the addon dev might not be aware of, then nothing gets fixed.
And I really wish people would do likewise for my skin a bit more often. What I intended to do in this case was to send a couple of discreet PM's to the script authors in question to let them know there is a problem. I still think a general heads up for script writers is an excellent idea, just some people might not take kindly to having faults pointed out in public. Me I don't care as I have a hide like a rhino.

Wyrm
If required a FULL debug log can now be submitted from the skin in settings->skin settings->support. Or follow instructions here if you can't access skin settings.

FAQ's located at :- http://kodi.wiki/view/Add-on:AppTV
Reply

Logout Mark Read Team Forum Stats Members Help
Reduce default script shutdown time0