From cd65a9398901f2ede2d002acd12ac0724fe13ee8 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Mon, 17 Oct 2016 22:34:15 +0200 Subject: [PATCH] Fix Kodi crashing on low powered devices - Fixes #126 --- resources/language/English/strings.xml | 2 +- resources/language/German/strings.xml | 2 +- resources/lib/artwork.py | 11 +++++++++-- resources/lib/initialsetup.py | 12 ++++++++---- resources/settings.xml | 8 ++++---- service.py | 2 ++ 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index a55487aa..d1c01c2c 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -306,7 +306,7 @@ Download movie set/collection art from FanArtTV Don't ask to pick a certain stream/quality Always pick best quality for trailers - Sleep between art downloads [ms] + Kodi runs on a low-power device (e.g. Raspberry Pi) Artwork diff --git a/resources/language/German/strings.xml b/resources/language/German/strings.xml index cef530e7..c6f13372 100644 --- a/resources/language/German/strings.xml +++ b/resources/language/German/strings.xml @@ -32,7 +32,7 @@ FanArtTV Film-Sets/Collections Bilder herunterladen Nicht fragen, welcher Stream/Qualität gespielt wird Trailer immer in der besten Qualität abspielen - Wartezeit zwischen Bilder downloads [ms] + Kodi läuft auf langsamer Hardware (z.B. Raspberry Pi) Artwork Verbindung diff --git a/resources/lib/artwork.py b/resources/lib/artwork.py index b226e82c..28f99b6e 100644 --- a/resources/lib/artwork.py +++ b/resources/lib/artwork.py @@ -132,7 +132,14 @@ def double_urldecode(text): class Image_Cache_Thread(Thread): xbmc_host = 'localhost' xbmc_port, xbmc_username, xbmc_password = setKodiWebServerDetails() - sleep_between = int(settings('sleep_between_art_downloads')) + sleep_between = 50 + if settings('low_powered_device') == 'true': + # Low CPU, potentially issues with limited number of threads + # Hence let Kodi wait till download is successful + timeout = (35.1, 35.1) + else: + # High CPU, no issue with limited number of threads + timeout = (0.01, 0.01) def __init__(self, queue): self.queue = queue @@ -164,7 +171,7 @@ class Image_Cache_Thread(Thread): url="http://%s:%s/image/image://%s" % (self.xbmc_host, self.xbmc_port, url), auth=(self.xbmc_username, self.xbmc_password), - timeout=(0.01, 0.01)) + timeout=self.timeout) except requests.Timeout: # We don't need the result, only trigger Kodi to start the # download. All is well diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 0ceab110..e931adcf 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -417,6 +417,14 @@ class InitialSetup(): if settings('InstallQuestionsAnswered') == 'true': return + # Is your Kodi installed on a low-powered device like a Raspberry Pi? + # If yes, then we will reduce the strain on Kodi to prevent it from + # crashing. + if dialog.yesno(heading=addonName, line1=lang(39072)): + settings('low_powered_device', value="true") + else: + settings('low_powered_device', value="false") + # Additional settings where the user needs to choose # Direct paths (\\NAS\mymovie.mkv) or addon (http)? goToSettings = False @@ -463,10 +471,6 @@ class InitialSetup(): log.debug("User opted to use FanArtTV") settings('FanartTV', value="true") - # Is your Kodi installed on a low-powered device like a Raspberry Pi? - # If yes, then we will reduce the strain on Kodi to prevent it from - # crashing. - # Make sure that we only ask these questions upon first installation settings('InstallQuestionsAnswered', value='true') diff --git a/resources/settings.xml b/resources/settings.xml index f12684ad..21e16774 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -43,11 +43,11 @@ - - - + + + - + diff --git a/service.py b/service.py index a68d42e0..efdbd2d8 100644 --- a/service.py +++ b/service.py @@ -85,6 +85,8 @@ class Service(): log.warn("%s Version: %s" % (addonName, self.clientInfo.getVersion())) log.warn("Using plugin paths: %s" % (settings('useDirectPaths') != "true")) + log.warn("Using a low powered device: %s" + % settings('low_powered_device')) log.warn("Log Level: %s" % logLevel) # Reset window props for profile switch