henryjfry / repository.thenewdiamond

9 stars 4 forks source link

[Bug] AutoCompletion for virtual keyboard crashes for android #5

Closed Goldenfreddy0703 closed 2 years ago

Goldenfreddy0703 commented 2 years ago

Hey there, I really appreciate you releasing AutoCompletion but one bug I noticed is that on Android, whenever you click on a result, it crashes kodi.

This is been a known bug in the past on kodi 18 but a person on reddit found a solution to the fix: https://www.reddit.com/r/Addons4Kodi/comments/ijku3f/possible_fix_for_autocomplete_crash_on_kodi_18/

I hope that reddit link will help you out in order to fix this bug for Android users.

Thank you

Goldenfreddy0703 commented 2 years ago

Hey so sorry i took too long but here is the kodi log from my android tv. kodi.log

-I will be honest, i don't think this log file will help as much cause i did not see any errors except my twitch error which is normal. -If you want to reproduce the issue, you can download an android emulator: https://www.gameloop.com/us/en-us

henryjfry commented 2 years ago

I posted an update, v2.0.3 which hopefully fixes the issue. I think it was a timing issue so i put some pauses between selecting the autocomplete option and populating the input box.

Let me know if it works.

Yeah looking at your log doesnt provide too much information as it appeared to totally crash. Which happened for me too on android, v2.0.3 appeared to fix the issue for me. But its typical that that kind of extreme crash in kodi provides no debug information at all.

henryjfry commented 2 years ago

Ok so in plugin.py it just needs the following pauses:

            if int(xbmc.getInfoLabel('System.BuildVersion')[:2]) > 17:
                xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
            else:
                xbmc.executebuiltin('Dialog.Close(busydialog)')
            xbmc.sleep(300)
            window.setFocusId(312)
            search_str = str(params.get("id"))
            xbmc.sleep(300)
kolekan commented 2 years ago

V.2.0.3 fix crashes but not for all the popular addons that have search function. e.g Using Search in Seren and TheOath through autocompletion v.2.0.3 make Kodi crash Using Search in EIM or Addon browser behave as expected.

henryjfry commented 2 years ago

2.0.3 has the 250ms pauses setup, it might need a bit longer than that. Try the modification posted above (300ms pauses)

And let me know if it works? ~/.kodi/addons/plugin.program.autocompletion/plugin.py

kolekan commented 2 years ago

2.0.3 has the 250ms pauses setup, it might need a bit longer than that. Try the modification posted above (300ms pauses)

And let me know if it works? ~/.kodi/addons/plugin.program.autocompletion/plugin.py

No it doesn't work. Actually there is a working matrix autocompletion fork that work. Look here https://github.com/DaedalusBLN/DaedalusBLN.github.io/tree/master/matrix/plugin.program.autocompletion

Goldenfreddy0703 commented 2 years ago

2.0.3 has the 250ms pauses setup, it might need a bit longer than that. Try the modification posted above (300ms pauses)

And let me know if it works? ~/.kodi/addons/plugin.program.autocompletion/plugin.py

Hey so i just tried it today and it does not work.

henryjfry commented 2 years ago

Are you using estuary skin? I've been testing and in various places the autocomplete list in estuary appears to be fubar. So it works in the addons search, but doesnt work in youtube and causes an immediate crash.

It appears to be the actual listitems which contain the autocomplete options, clicking on them will cause kodi to crash, even if the actual plugin function completes successfully.

I tested the exact same jsonrpc call from a commandline, which worked, and replicated it exactly in the addon (so sending via requests to the ip address of the kodi box) and it reported success in the logs, but kodi still crashed.

So it looks like android users will just have to raise this as an issue on the kodi github and wait for a fix.

So this is what I tried, as you can see it doesnt touch the "executeJSONRPC" command which I thought was actually causing the error and needed pauses before it runs. The same command sent from a python script will work, just not when you click on an autocomplete option in certain estuary screens:

        elif info == 'selectautocomplete':
            if params.get("handle"):
                xbmcplugin.setResolvedUrl(handle=int(params.get("handle")),
                                          succeeded=False,
                                          listitem=xbmcgui.ListItem())
            #try:
            #    window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
            #except Exception:
            #    return None
            #xbmc.executebuiltin('Control.SetFocus(0)')

            #if xbmc.getCondVisibility('Window.IsActive(10138)'):
            #    #xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
            #    xbmc.sleep(50)
            #    #xbmc.executebuiltin('Dialog.Close(busydialog)')
            xbmc.sleep(300)
            search_str = str(params.get("id"))
            kodi_params = str('{"jsonrpc": "2.0", "method": "Input.SendText", "params": {"text": "'+str(search_str)+'", "done": false}, "id": 1}')

            #services_webserverpassword = xbmc.getSetting("services.webserverpassword")
            #services_webserverusername = xbmc.getSetting("services.webserverusername")
            services_webserverpassword = json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"services.webserverpassword"}, "id":1}'))['result']['value']
            services_webserverusername = json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"services.webserverusername"}, "id":1}'))['result']['value']
            services_webserverport = json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"services.webserverport"}, "id":1}'))['result']['value']
            #xbmc.log(str(services_webserverusername)+'===>PHIL', level=xbmc.LOGINFO)
            #xbmc.log(str(services_webserverport)+'===>PHIL', level=xbmc.LOGINFO)
            #xbmc.log(str(xbmc.getIPAddress())+'===>PHIL', level=xbmc.LOGINFO)
            #xbmc.log(str(services_webserverpassword)+'===>PHIL', level=xbmc.LOGINFO)
            kodi_credentials = '%s:%s' % (services_webserverusername,services_webserverpassword)
            kodi_encoded_credentials = base64.b64encode(kodi_credentials.encode('utf-8')) 
            kodi_authorization = b'Basic ' + kodi_encoded_credentials 
            kodi_header = { 'Content-Type': 'application/json', 'Authorization': kodi_authorization } 
            kodi_ip = str(xbmc.getIPAddress())
            kodi_port = str(services_webserverport)
            kodi_url = 'http://' + str(kodi_ip) + ':' + str(kodi_port) + '/jsonrpc'

            #focus_id = 300
            #if xbmc.getInfoLabel('Control.GetLabel(312).index(0)') == 'OK':
            #    focus_id = 312
            #elif xbmc.getInfoLabel('Control.GetLabel(300).index(0)') == 'OK':
            #    focus_id = 300
            #window.setFocusId(focus_id)

            #xbmc.executebuiltin('Control.SetFocus(0)')
            #xbmc.sleep(100)
            kodi_response = requests.post(kodi_url, headers=kodi_header, data=kodi_params)
            xbmc.sleep(100)
            kodi_response = requests.post(kodi_url, headers=kodi_header, data=kodi_params)
            json_data = json.dumps(kodi_response.json(), indent=4, sort_keys=True)
            json_object  = json.loads(json_data)
            xbmc.log(str(json_object)+'===>PHIL', level=xbmc.LOGINFO)
            #if xbmc.getInfoLabel('Control.GetLabel(312).index(1)') != '':
            #    focus_id = 312
            #elif xbmc.getInfoLabel('Control.GetLabel(300).index(1)') != '':
            #    focus_id = 300
            #window.setFocusId(focus_id)
            exit()
Goldenfreddy0703 commented 2 years ago

Hey so i was not using the estuary skin, i was using osmc skin, you are right that addon search is working but other addons like seren and youtube are not working so we may have to write about raising and issue on the kodi github.

kolekan commented 2 years ago

Hey so i was not using the estuary skin, i was using osmc skin, you are right that addon search is working but other addons like seren and youtube are not working so we may have to write about raising and issue on the kodi github.

Does this fork work for you on any addon's search? https://github.com/DaedalusBLN/DaedalusBLN.github.io/tree/master/matrix/plugin.program.autocompletion

Goldenfreddy0703 commented 2 years ago

Hey so i was not using the estuary skin, i was using osmc skin, you are right that addon search is working but other addons like seren and youtube are not working so we may have to write about raising and issue on the kodi github.

Does this fork work for you on any addon's search? https://github.com/DaedalusBLN/DaedalusBLN.github.io/tree/master/matrix/plugin.program.autocompletion

It does, thank you

henryjfry commented 2 years ago

Ive updated based upon that fork, so the version in my repo should hopefully work now.

Goldenfreddy0703 commented 2 years ago

Hey sorry I accidentally clicked closed for a sec, let me test it out real quick and see if it's working.

Goldenfreddy0703 commented 2 years ago

Hey, its working super well and alot faster for me responding to the results. Thank you very much for fixing this issue.

henryjfry commented 2 years ago

Right I'm going to close this one then.