Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
Solved Kodi frequently crashes when redrawing the UI
#1
I thought this was originally linked to python changes in Debian (Trixie) and the Matrix version of Kodi, but I've updated to Omega and the problem still persists.
Kodi works fine, when it works. If the UI loads, and lasts more than a few seconds, then I'll be able to get whatever I need done; I can move around all of the menus, browse and change things, but as soon as I play a video, or watch TV, and then stop (re-drawing the UI) there's a hit-and-miss chance that Kodi will crash.

I've tried different skins, so I know it isn't a skin issue, and I've tried disabling addons, which doesn't seem to be the problem either. (hence reference in the pastebin to missing iplayer and amazon)

Anyway, crash log here.
Full debug log here (different occasions, same crash type)
Reply
#2
Please try to get a Python stacktrace:

1. Stop kodi
2. SSH into your Debian box as kodi user
3. Export debuginfo URL and start kodi.bin under gdb directly:

shell:

export DEBUGINFOD_URLS="https://debuginfod.debian.net"
gdb /usr/lib/kodi/kodi.bin

4. In GDB shell, press "y" to load debuginfos and wait for them to load (can take a while but only first time!)
5. Type "run" and enter to start Kodi
6. Try to get crash, if kodi crashes UI freezes and gdb prompt becomes active
7. Type "set logging enabled on", enter,  "set logging file gdb.txt", enter, "py-bt-full"
8. Wait for log to complete and close gdb by "q" and confirming Kodi will be killed
9. Post the trace gdb.txt
Maintainer of Kodi from Debian | Got an issue with Kodi from Debian? Report it here: Kodi from Debian - Support Thread
Reply
#3
So here's the debug output. Looks like something to do with the ITVX plugin.

If this is the cause, then I presume that even if you disable a Kodi plugin, it still loads and impacts the system somehow, because disabling the plugin didn't stop the crashes. Completely removing the plugin (only a 10 minute test,) seems to have fixed it for now, though.

gdb.txt:
#3 Frame 0x7fffc5c01bc0, for file /usr/lib/python3/dist-packages/simplejson/errors.py, line 7, in linecol (doc='no continue watching items', pos=0)
    lineno = doc.count('\n', 0, pos) + 1
#3 Frame 0x7fffc5c01ae8, for file /usr/lib/python3/dist-packages/simplejson/errors.py, line 16, in errmsg (msg='Expecting value', doc='no continue watching items', pos=0, end=None)
    lineno, colno = linecol(doc, pos)
#3 Frame 0x7fffc5c01a30, for file /usr/lib/python3/dist-packages/simplejson/errors.py, line 41, in __init__ (self=<JSONDecodeError at remote 0x7fffb8206e40>, msg='Expecting value', doc='no continue watching items', pos=0, end=None)
    ValueError.__init__(self, errmsg(msg, doc, pos, end=end))
#18 Frame 0x7fffc5c01980, for file /usr/lib/python3/dist-packages/simplejson/decoder.py, line 416, in raw_decode (self=<JSONDecoder(encoding='utf-8', object_hook=None, object_pairs_hook=None, parse_float=<type at remote 0x7ffff7b58600>, parse_int=<type at remote 0x7ffff7b5adc0>, parse_constant=None, strict=True, parse_object=<function at remote 0x7fffb21e3b00>, parse_array=<function at remote 0x7fffb21e2200>, parse_string=<built-in method scanstring of module object at remote 0x7fff2c3f27a0>, memo={}, scan_once=<simplejson._speedups.Scanner at remote 0x7fff2398a2d0>) at remote 0x7fff44236420>, s='no continue watching items', idx=0, _w=<builtin_method at remote 0x7fffa4f93d80>, _PY3=True, ord0=110)
    return self.scan_once(s, idx=_w(s, idx).end())
#18 Frame 0x7fffc5c018c8, for file /usr/lib/python3/dist-packages/simplejson/decoder.py, line 386, in decode (self=<JSONDecoder(encoding='utf-8', object_hook=None, object_pairs_hook=None, parse_float=<type at remote 0x7ffff7b58600>, parse_int=<type at remote 0x7ffff7b5adc0>, parse_constant=None, strict=True, parse_object=<function at remote 0x7fffb21e3b00>, parse_array=<function at remote 0x7fffb21e2200>, parse_string=<built-in method scanstring of module object at remote 0x7fff2c3f27a0>, memo={}, scan_once=<simplejson._speedups.Scanner at remote 0x7fff2398a2d0>) at remote 0x7fff44236420>, s='no continue watching items', _w=<builtin_method at remote 0x7fffa4f93f10>, _PY3=True)
    obj, end = self.raw_decode(s)
#18 Frame 0x7fffc5c01800, for file /usr/lib/python3/dist-packages/simplejson/__init__.py, line 514, in loads (s='no continue watching items', encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, use_decimal=False, allow_nan=False, kw={})
    return _default_decoder.decode(s)
#18 Frame 0x7fffc5c01768, for file /home/james/.kodi/addons/script.module.requests/lib/requests/models.py, line 971, in json (self=<Response(_content=b'no continue watching items', _content_consumed=True, _next=None, status_code=404, headers=<CaseInsensitiveDict(_store={'content-type': ('Content-Type', 'text/plain; charset=UTF-8'), 'content-length': ('Content-Length', '26'), 'connection': ('Connection', 'keep-alive'), 'access-control-allow-headers': ('access-control-allow-headers', 'accept, authorization, content-type'), 'access-control-allow-methods': ('access-control-allow-methods', 'OPTIONS, GET, HEAD'), 'access-control-allow-origin': ('access-control-allow-origin', '*'), 'access-control-expose-headers': ('access-control-expose-headers', '*'), 'date': ('date', 'Sun, 01 Sep 2024 17:34:19 GMT'), 'server': ('server', 'istio-envoy'), 'trace-id': ('trace-id', '3c01880f55c6c31afe7da1cc3803e551'), 'x-content-type-options': ('x-content-type-options', 'nosniff'), 'x-envoy-decorator-operation': ('x-envoy-decorator-opera...(truncated)
    return complexjson.loads(self.text, **kwargs)
#18 Frame 0x7fffc5c01688, for file /home/james/.kodi/addons/plugin.video.viwx/resources/lib/fetch.py, line 271, in web_request (method='GET', url='https://content.prd.user.itv.com/lastwatched/user/4610af58-a330-4640-b519-4cfe54a89b9e/ctv?features=hd,progressive,single-track,mpeg-dash,widevine,widevine-download,inband-ttml,hls,aes,inband-webvtt,outband-webvtt,inband-audio-description', headers={'Accept': 'application/json', 'accept': 'application/vnd.user.content.v1+json', 'authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGguaXR2LmNvbSIsInN1YiI6IjQ2MTBhZjU4LWEzMzAtNDY0MC1iNTE5LTRjZmU1NGE4OWI5ZSIsImV4cCI6MTcyNTI5OTgyNCwiaWF0IjoxNzI1MjA5ODI0LCJicm9hZGNhc3RFcnJvck1zZyI6IiIsImJyb2FkY2FzdFJlc3BvbnNlQ29kZSI6IjIwMCIsImJyb2FkY2FzdGVyIjoiSVRWIiwiaXNBY3RpdmUiOnRydWUsIm5vbmNlIjoieTZlZzhTeWo0RElPQ2tEa0JSN3oiLCJuYW1lIjoiQ2F0aGVyaW5lIiwic2NvcGUiOiJjb250ZW50IiwiZW50aXRsZW1lbnRzIjpbXSwicGF5bWVudFNvdXJjZSI6IiIsInNob3dQcml2YWN5Tm90aWNlIjpmYWxzZSwidW5kZXIxOCI6ZmFsc2UsImFjY291bnRQcm9maWxlSWRJblVzZ...(truncated)
    resp_data = resp.json()
#18 Frame 0x7fffc5c015e8, for file /home/james/.kodi/addons/plugin.video.viwx/resources/lib/fetch.py, line 315, in get_json (url='https://content.prd.user.itv.com/lastwatched/user/4610af58-a330-4640-b519-4cfe54a89b9e/ctv?features=hd,progressive,single-track,mpeg-dash,widevine,widevine-download,inband-ttml,hls,aes,inband-webvtt,outband-webvtt,inband-audio-description', headers={'accept': 'application/vnd.user.content.v1+json', 'authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGguaXR2LmNvbSIsInN1YiI6IjQ2MTBhZjU4LWEzMzAtNDY0MC1iNTE5LTRjZmU1NGE4OWI5ZSIsImV4cCI6MTcyNTI5OTgyNCwiaWF0IjoxNzI1MjA5ODI0LCJicm9hZGNhc3RFcnJvck1zZyI6IiIsImJyb2FkY2FzdFJlc3BvbnNlQ29kZSI6IjIwMCIsImJyb2FkY2FzdGVyIjoiSVRWIiwiaXNBY3RpdmUiOnRydWUsIm5vbmNlIjoieTZlZzhTeWo0RElPQ2tEa0JSN3oiLCJuYW1lIjoiQ2F0aGVyaW5lIiwic2NvcGUiOiJjb250ZW50IiwiZW50aXRsZW1lbnRzIjpbXSwicGF5bWVudFNvdXJjZSI6IiIsInNob3dQcml2YWN5Tm90aWNlIjpmYWxzZSwidW5kZXIxOCI6ZmFsc2UsImFjY291bnRQcm9maWxlSWRJblVzZSI6bnVsbCwicmVnaW9uIjoiY2VudHJhbF9lYXN0IiwicG9z...(truncated)
    resp = web_request('GET', url, dflt_headers, **kwargs)
#18 Frame 0x7fffc5c01510, for file /home/james/.kodi/addons/plugin.video.viwx/resources/lib/itv_account.py, line 277, in fetch_authenticated (funct=<function at remote 0x7fff5cd536a0>, url='https://content.prd.user.itv.com/lastwatched/user/4610af58-a330-4640-b519-4cfe54a89b9e/ctv?features=hd,progressive,single-track,mpeg-dash,widevine,widevine-download,inband-ttml,hls,aes,inband-webvtt,outband-webvtt,inband-audio-description', login=True, kwargs={'headers': {'accept': 'application/vnd.user.content.v1+json', 'authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGguaXR2LmNvbSIsInN1YiI6IjQ2MTBhZjU4LWEzMzAtNDY0MC1iNTE5LTRjZmU1NGE4OWI5ZSIsImV4cCI6MTcyNTI5OTgyNCwiaWF0IjoxNzI1MjA5ODI0LCJicm9hZGNhc3RFcnJvck1zZyI6IiIsImJyb2FkY2FzdFJlc3BvbnNlQ29kZSI6IjIwMCIsImJyb2FkY2FzdGVyIjoiSVRWIiwiaXNBY3RpdmUiOnRydWUsIm5vbmNlIjoieTZlZzhTeWo0RElPQ2tEa0JSN3oiLCJuYW1lIjoiQ2F0aGVyaW5lIiwic2NvcGUiOiJjb250ZW50IiwiZW50aXRsZW1lbnRzIjpbXSwicGF5bWVudFNvdXJjZSI6IiIsInNob3dQcml2YWN5Tm90aWNlIjpmYWxzZSwidW5kZXIxOCI6Z...(truncated)
    return funct(url=url, **kwargs)
#18 Frame 0x7fffc5c01448, for file /home/james/.kodi/addons/plugin.video.viwx/resources/lib/itvx.py, line 528, in get_last_watched (user_id='4610af58-a330-4640-b519-4cfe54a89b9e', cache_key='last_watched_4610af58-a330-4640-b519-4cfe54a89b9e', cached_data=None, url='https://content.prd.user.itv.com/lastwatched/user/4610af58-a330-4640-b519-4cfe54a89b9e/ctv?features=hd,progressive,single-track,mpeg-dash,widevine,widevine-download,inband-ttml,hls,aes,inband-webvtt,outband-webvtt,inband-audio-description', header={'accept': 'application/vnd.user.content.v1+json', 'authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGguaXR2LmNvbSIsInN1YiI6IjQ2MTBhZjU4LWEzMzAtNDY0MC1iNTE5LTRjZmU1NGE4OWI5ZSIsImV4cCI6MTcyNTI5OTgyNCwiaWF0IjoxNzI1MjA5ODI0LCJicm9hZGNhc3RFcnJvck1zZyI6IiIsImJyb2FkY2FzdFJlc3BvbnNlQ29kZSI6IjIwMCIsImJyb2FkY2FzdGVyIjoiSVRWIiwiaXNBY3RpdmUiOnRydWUsIm5vbmNlIjoieTZlZzhTeWo0RElPQ2tEa0JSN3oiLCJuYW1lIjoiQ2F0aGVyaW5lIiwic2NvcGUiOiJjb250ZW50IiwiZW50aXRsZW1lbnRzIjpbXSwicGF5bWVudFNvdXJjZSI6I...(truncated)
    data = itv_account.fetch_authenticated(fetch.get_json, url, headers=header)
#18 Frame 0x7fffa6d3d288, for file /home/james/.kodi/addons/plugin.video.viwx/resources/lib/main.py, line 254, in generic_list (addon=<Route(_title='Continue Watching', handle=9, update_listing=False, category='Continue Watching', cache_to_disc=True, redirect_single_item=False, sort_methods=[40, 9, 3], content_type='videos', autosort=False) at remote 0x7fff38178290>, list_type='watching', filter_char=None, page_nr=0)
    shows_list = itvx.get_last_watched()
#27 Frame 0x7fffc5c013b8, for file /home/james/.kodi/addons/plugin.video.viwx/resources/lib/main.py, line 79, in wrapper (args=(<Route(_title='Continue Watching', handle=9, update_listing=False, category='Continue Watching', cache_to_disc=True, redirect_single_item=False, sort_methods=[40, 9, 3], content_type='videos', autosort=False) at remote 0x7fff38178290>,), kwargs={'list_type': 'watching', 'filter_char': None}, result=<generator at remote 0x7fffa6d3d240>)
    result = list(result)
#27 Frame 0x7fffc5c01328, for file /home/james/.kodi/addons/script.module.codequick/lib/codequick/script.py, line 169, in __call__ (self=<Route(_title='Continue Watching', handle=9, update_listing=False, category='Continue Watching', cache_to_disc=True, redirect_single_item=False, sort_methods=[40, 9, 3], content_type='videos', autosort=False) at remote 0x7fff38178290>, route=<Route at remote 0x7fff21192080>, args=[], kwargs={'list_type': 'watching', 'filter_char': None})
    return route.function(self, *args, **kwargs)
#27 Frame 0x7fffc5c01268, for file /home/james/.kodi/addons/script.module.codequick/lib/codequick/route.py, line 195, in __call__ (self=<Route(_title='Continue Watching', handle=9, update_listing=False, category='Continue Watching', cache_to_disc=True, redirect_single_item=False, sort_methods=[40, 9, 3], content_type='videos', autosort=False) at remote 0x7fff38178290>, route=<Route at remote 0x7fff21192080>, args=[], kwargs={'list_type': 'watching', 'filter_char': None}, cache_ttl=-1, cache=None, session_id='a4a6d7cf9fd3f859bf43ea471629807bb5a8fa6d')
    results = super(Route, self).__call__(route, args, kwargs)
#27 Frame 0x7fffc5c011c8, for file /home/james/.kodi/addons/plugin.video.viwx/resources/lib/cc_patch.py, line 29, in patched_call (self=<Route(_title='Continue Watching', handle=9, update_listing=False, category='Continue Watching', cache_to_disc=True, redirect_single_item=False, sort_methods=[40, 9, 3], content_type='videos', autosort=False) at remote 0x7fff38178290>, route=<Route at remote 0x7fff21192080>, args=[], kwargs={'list_type': 'watching', 'filter_char': None})
    original_call(self, route, args, kwargs)
#33 Frame 0x7fffc5c010f0, for file /home/james/.kodi/addons/script.module.codequick/lib/codequick/support.py, line 306, in run_callback (self=<Dispatcher(registered_delayed=[(<function at remote 0x7fff2cd7d940>, (), {}, 0)], registered_routes={'root': <Route at remote 0x7fff21192140>, '/resources/lib/main/sub_menu_my_itvx': <Route at remote 0x7fff211920e0>, '/resources/lib/main/wrapper.generic_list': <Route at remote 0x7fff21192080>, '/resources/lib/main/sub_menu_live': <Route at remote 0x7fff21191fc0>, '/resources/lib/main/list_collections': <Route at remote 0x7fff21191f60>, '/resources/lib/main/wrapper.list_collection_content': <Route at remote 0x7fff21191f00>, '/resources/lib/main/list_categories': <Route at remote 0x7fff21191e40>, '/resources/lib/main/wrapper.list_category': <Route at remote 0x7fff21191de0>, '/resources/lib/main/wrapper.list_news_sub_category': <Route at remote 0x7fff21191d20>, '/resources/lib/main/wrapper.list_productions': <Route at remote 0x7fff21191c60>, '/resources/lib/main/wrapper.do_se...(truncated)
    redirect = parent_ins(route, arg_params, self.callback_params)
#33 Frame 0x7fffc5c01078, for file /home/james/.kodi/addons/plugin.video.viwx/resources/lib/main.py, line 647, in run ()
    if isinstance(cc_run(), Exception):
#33 Frame 0x7fffc5c01020, for file /home/james/.kodi/addons/plugin.video.viwx/addon.py, line 21, in <module> ()
    main.run()

Happy to report this as a bug in their git, if I know what I'm reporting.
Reply
#4
Get watched status response from server is malformed and that error is not handled properly.
Maintainer of Kodi from Debian | Got an issue with Kodi from Debian? Report it here: Kodi from Debian - Support Thread
Reply
#5
Reported: https://forum.kodi.tv/showthread.php?tid...pid3208467
Maintainer of Kodi from Debian | Got an issue with Kodi from Debian? Report it here: Kodi from Debian - Support Thread
Reply
#6
Thanks for the notification @basilgello, I'll have a look shortly.

Looks somewhat similar to this recent comment on github. Was that by one of you guys, or is it something else?
Reply
#7
Definitely the topic author's repost (compare user UUID here and there! Smile )
Maintainer of Kodi from Debian | Got an issue with Kodi from Debian? Report it here: Kodi from Debian - Support Thread
Reply
#8
(2024-09-05, 19:44)basilgello Wrote: Definitely the topic author's repost (compare user UUID here and there! Smile )

Ha, well spotted! He doesn't seem to be very interested in a solution though...
Quote:Get watched status response from server is malformed and that error is not handled properly.
Absolutely, but the error should be handled by simplejson. Simplejson should raise a JSONDecodeError when a string is not valid JSON, and it normally does. The gdb trace shows that Kodi crashed when simplejson was in the process of creating the exception. More specifically, while creating the error description. 

The requests package still prefers simplejson above the json package from python's standard lib. Apparently the OP has simplejson installed system wide. Since kodi on linux uses the system's interpreter, requests will detect the presence of simplejson and  uses that. I don't know why simplejson crashes Kodi, but there's nothing that viwX can do to solve it. 

More general, I don't think that pure python code, like a plugin is, is capable of crashing Kodi. The worst thing it can do is exit with an unhandled exception. Which should be avoided, but should not crash Kodi. 
Quote: ... I presume that even if you disable a Kodi plugin, it still loads and impacts the system somehow. ...
No, that's not entirely the right assessment. Some addon's register themselves with an additional background service, but viwX doesn't. AFAIK, Kodi does not load plugins on it's own initiative, even if enabled. If it does, then something else runs viwx, e.g. script.embuary.helper
Reply
#9
(2024-09-06, 02:52)kereltje Wrote:  He doesn't seem to be very interested in a solution though...
No, not disinterested, just busy with work and currently the Kodi box is also the family's main PC...
(2024-09-06, 02:52)kereltje Wrote: The requests package still prefers simplejson above the json package from python's standard lib. Apparently the OP has simplejson installed system wide. Since kodi on linux uses the system's interpreter, requests will detect the presence of simplejson and  uses that. I don't know why simplejson crashes Kodi, but there's nothing that viwX can do to solve it. 
I was going to submit an issue in the git, but from reading this, seems this is a broader kodi/python/linux issue - I presume that the preference for simplejson (which looks like it's not catching the issue in time, or at the right point, before something else causes the crash?) can't be changed and this might just be something I'm stuck with? I think that occasionally, Amazon Prime or Netflix can cause this crash, too.
(2024-09-06, 02:52)kereltje Wrote: No, that's not entirely the right assessment. Some addon's register themselves with an additional background service, but viwX doesn't. AFAIK, Kodi does not load plugins on it's own initiative, even if enabled. If it does, then something else runs viwx, e.g. script.embuary.helper
Yes, crashes were worse if I added a homescreen link to load the plugin, which led to the disabling each one in turn to try and track down the issue.
Reply
#10
Quote:I presume that the preference for simplejson ... can't be changed and this might just be something I'm stuck with?
Exactly, or you'll have to manually edit some code in the requests package, which will be overwritten again once requests is being updated.
 
Quote:I think that occasionally, Amazon Prime or Netflix can cause this crash, too.
That's very well possible. Requests is a package used by a lot of plugins to handle their web requests. If such a request expects the server to return JSON data, but the server for some reason doesn't, you could run into the same issue. e.g. ITVX normally returns JSON data with all watched programmes when the viwX requests /lastwatched. However, from your log it seems that it sometimes return just a plain text messages when there's nothing on the last watched list.

A q
Reply
#11
Quote:I presume that the preference for simplejson ... can't be changed and this might just be something I'm stuck with?
Exactly, or you'll have to manually edit some code in the requests package, which will be overwritten again once requests is being updated.
 
Quote:I think that occasionally, Amazon Prime or Netflix can cause this crash, too.
That's very well possible. Requests is a package used by a lot of plugins to handle their web requests. If such a request expects the server to return JSON data, but the server for some reason doesn't, you could run into the same issue. e.g. ITVX normally returns JSON data with all watched programmes when viwX requests /watch/lastwatched. However, from your log it seems that it sometimes return just a plain text messages when there's nothing on the last watched list.

A quick workaround could be to just watch some programme on ITVX, on any device, just as long you're signed in with the same account you use on Kodi. From that moment on the last watched list will have at least one item and will return valid JSON. This, however, does not solve the underlying problem, and you'll loose an easy way to test it.

Simplejson should, and normally does, just raise an exception. Something on your system is wrong that causes the crash. It may be simplejson itself, or some underlying library it uses.
I'm not quite sure why simplejson is in your system's python packages. Is that a Debian thing @basilgello? If it's not needed you could try to uninstall simplejson; requests will then use python's build-in json module.

It might be a good idea to check if simplejson on it's own crashes. You could easily test that by doing a simplejson.loads('some texts') in a python interpreter. If simplejson behaves OK, it should just raise an exception and print some lines in the interpreter. If it has the same issue it has on Kodi, it will crash the interpreter and you'll be back at the shell prompt.

edit: Apologies for the double post. Must have been caused by something between the keyboard and the chair.
Reply
#12
(2024-09-07, 13:54)kereltje Wrote: A quick workaround could be to just watch some programme on ITVX, on any device, just as long you're signed in with the same account you use on Kodi. From that moment on the last watched list will have at least one item and will return valid JSON. This, however, does not solve the underlying problem, and you'll loose an easy way to test it.
I can certainly give this a try.
(2024-09-07, 13:54)kereltje Wrote: Simplejson should, and normally does, just raise an exception. Something on your system is wrong that causes the crash. It may be simplejson itself, or some underlying library it uses.
I'm not quite sure why simplejson is in your system's python packages. Is that a Debian thing @basilgello? If it's not needed you could try to uninstall simplejson; requests will then use python's build-in json module.
on my system, python3-simplejson is the only json package installed. I can't remove it, though, as my PVR (mythTV) depends upon it.
(2024-09-07, 13:54)kereltje Wrote: It might be a good idea to check if simplejson on it's own crashes. You could easily test that by doing a simplejson.loads('some texts') in a python interpreter. If simplejson behaves OK, it should just raise an exception and print some lines in the interpreter. If it has the same issue it has on Kodi, it will crash the interpreter and you'll be back at the shell prompt.
Python isn't my strong suit, but I had a go, and got this, so simplejson seems to be behaving??
 
python3-simplejson:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 514, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 386, in decode
obj, end = self.raw_decode(s)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 416, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Reply
#13
Quote:I can certainly give this a try.
I hope you haven't already done so, because it'll make things much harder to test if you don't have a function that is guaranteed to return non-json data.
Quote:... , so simplejson seems to be behaving??
Yes it does...

The only things I can think of right now is to check what python version you ran by running these command in the interpeter:
python:

>>> import sys
>>> sys.version
>>> sys.executable

And at this stage It might be interesting to see what will happen if requests uses python's standard json module. To test that you'll have to edit some code in the requests package installed with Kodi.
  1. Navigate to /home/james/.kodi/addons/script.module.requests//lib/requests
  2. Locate the file compat.py, make a copy and name that something like compat.py.orig, just to have a backup of the original if anythings goes wrong.
  3. Open the original compat.py in a text editor and locate this piece of code, starting from line 30
    python:

    # json/simplejson module import resolution
    has_simplejson = False
    try:
        import simplejson as json

        has_simplejson = True
    except ImportError:
        import json
  4. Comment out everything between and including try and except, by placing a '#' at the start of the line. These lines are now comments and will not be executed by the Python interpreter.
  5. Remove the indents from the next line, so that 'import json' is at the start of the line.
    The code should now look like this:
    python:

    # json/simplejson module import resolution
    has_simplejson = False
    #try:
    #    import simplejson as json
    #
    #    has_simplejson = True
    #except ImportError:
    import json
  6. Save the file.
  7. Open kodi and enable 'debug logging'. And set 'log level' to debug in viwX's settings.
  8. Restart kodi and check. Probably best to run it under gdb again, so you'l have a trace in case anything fails and a log if it doesn't.
Please post the log regardless of the test results.
Reply
#14
(2024-09-08, 14:18)kereltje Wrote: The only things I can think of right now is to check what python version you ran by running these command in the interpeter:
python:

>>> import sys
>>> sys.version
>>> sys.executable
python:
Python 3.12.5 (main, Aug 22 2024, 13:11:09) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'3.12.5 (main, Aug 22 2024, 13:11:09) [GCC 14.2.0]'
>>> sys.executable
'/usr/bin/python3'

I'll try properly later, my daughter wants to 'just watch TV', but commenting out the simplejson part of the compat.py file throws up errors in kodi for a number of addons, the same error (more or less) for all of them:
kodi.log:
2024-09-08 14:32:21.432 T:66673 error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'IndentationError'>
Error Contents: unexpected indent (compat.py, line 37)
Traceback (most recent call last):
File "/home/james/.kodi/addons/plugin.video.viwx/addon.py", line 10, in <module>
from resources.lib import main
File "/home/james/.kodi/addons/plugin.video.viwx/resources/lib/main.py", line 14, in <module>
import requests
File "/home/james/.kodi/addons/script.module.requests/lib/requests/__init__.py", line 45, in <module>
from .exceptions import RequestsDependencyWarning
File "/home/james/.kodi/addons/script.module.requests/lib/requests/exceptions.py", line 9, in <module>
from .compat import JSONDecodeError as CompatJSONDecodeError
File "/home/james/.kodi/addons/script.module.requests/lib/requests/compat.py", line 37
import json
IndentationError: unexpected indent
-->End of Python script error report<--

Trying to load any of these addons tells me there's an error in compat.py, line 37, which is the, "import json" line. I'll come back with gdb log later.
Reply
#15
Python throws a IndentationError, meaning some code (i.e. 'import json') has illegal preceding spaces or tabs.
By commenting out the code from 'try' to 'except' the original indentation on line 37 has become illegal.

Have you done point 5?:
"Remove the indents from the next line, so that 'import json' is at the start of the line."
Reply

Logout Mark Read Team Forum Stats Members Help
Kodi frequently crashes when redrawing the UI0