Skip to content

Commit

Permalink
Hotkey: cache results from getHotkeyFunctions in InfoBarHotkey
Browse files Browse the repository at this point in the history
This commit solves an issue with channel changing or displaying the channel list.

It seems that getHotkeyFunctions results used directly on InfoBarHotkey unlike
HotkeySetup and HotkeySetupSelect where results are cached.

When getHotkeyFunctions is called directly it seems to cause a delay about two seconds
trying to load translation files.

Here is part of strace when pressing key down:

07:54:36.802713 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/Blindscan/locale/en_US.ISO8859-1/LC_MESSAGES/Blindscan.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:36.803627 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/Blindscan/locale/en_US/LC_MESSAGES/Blindscan.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:36.804421 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/Blindscan/locale/en.ISO8859-1/LC_MESSAGES/Blindscan.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:36.806185 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/Blindscan/locale/en/LC_MESSAGES/Blindscan.mo", {st_mode=S_IFREG|0644, st_size=3424, ...}) = 0
07:54:36.809350 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/Blindscan/locale/en_US.ISO8859-1/LC_MESSAGES/Blindscan.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:36.810581 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/Blindscan/locale/en_US/LC_MESSAGES/Blindscan.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:36.811586 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/Blindscan/locale/en.ISO8859-1/LC_MESSAGES/Blindscan.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:36.812566 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/Blindscan/locale/en/LC_MESSAGES/Blindscan.mo", {st_mode=S_IFREG|0644, st_size=3424, ...}) = 0
07:54:37.648853 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager/locale/en_US.ISO8859-1/LC_MESSAGES/DeviceManager.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:37.649916 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager/locale/en_US/LC_MESSAGES/DeviceManager.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:37.650818 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager/locale/en.ISO8859-1/LC_MESSAGES/DeviceManager.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:37.651687 stat64("/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager/locale/en/LC_MESSAGES/DeviceManager.mo", 0x7f9beea0) = -1 ENOENT (No such file or directory)
07:54:37.653404 stat64("/usr/share/enigma2/po/en_US.ISO8859-1/LC_MESSAGES/enigma2.mo", 0x7f9bedd0) = -1 ENOENT (No such file or directory)
07:54:37.654243 stat64("/usr/share/enigma2/po/en_US/LC_MESSAGES/enigma2.mo", 0x7f9bedd0) = -1 ENOENT (No such file or directory)
07:54:37.654936 stat64("/usr/share/enigma2/po/en.ISO8859-1/LC_MESSAGES/enigma2.mo", 0x7f9bedd0) = -1 ENOENT (No such file or directory)
07:54:37.655956 stat64("/usr/share/enigma2/po/en/LC_MESSAGES/enigma2.mo", {st_mode=S_IFREG|0644, st_size=151686, ...}) = 0
07:54:37.662523 stat64("/etc/ppanels", 0x7f9bf5e8) = -1 ENOENT (No such file or directory)
07:54:37.663243 stat64("/usr/script", 0x7f9bf5e8) = -1 ENOENT (No such file or directory)
07:54:37.664945 write(2, "[ActionMap] Keymap 'InfobarChannelSelection' -> Action = 'keyDown'.\n", 68[ActionMap] Keymap 'InfobarChannelSelection' -> Action = 'keyDown'.

Caching the result of getHotkeyFunction hides the above delay, although further investigation required because that issue become "noticable" after 06 August.
So most probably another commit made getHotkeyFunction less performant, since there is no change in HotKey.py the last months.
  • Loading branch information
athoik committed Sep 17, 2019
1 parent 244da6d commit 23c2495
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/python/Screens/Hotkey.py
Expand Up @@ -558,6 +558,7 @@ def action(self, contexts, action):
class InfoBarHotkey():
def __init__(self):
self.hotkeys = getHotkeys()
self.hotkeyFunctions = getHotkeyFunctions()
self["HotkeyButtonActions"] = helpableHotkeyActionMap(self, "HotkeyActions",

This comment has been minimized.

Copy link
@littlesat

littlesat Sep 17, 2019

Member

There is one disadvantege... when you add eg sh scripts on the box you need to restart e2... otherwise the script does not work. This was the reason why I did not cached this

dict((x[1],(self.hotkeyGlobal, boundFunction(self.getHelpText, x[1]))) for x in self.hotkeys), -10)

Expand All @@ -572,7 +573,7 @@ def getKeyFunctions(self, key):
elif x.startswith("Zap"):
selected.append(((_("Zap to") + " " + ServiceReference(eServiceReference(x.split("/", 1)[1]).toString()).getServiceName()), x))
else:
function = list(function for function in getHotkeyFunctions() if function[1] == x )
function = list(function for function in self.hotkeyFunctions if function[1] == x )
if function:
selected.append(function[0])
return selected
Expand Down

0 comments on commit 23c2495

Please sign in to comment.