Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstart bridge fails when using profiles without autologin #728

Open
RabidArts opened this issue May 14, 2015 · 9 comments
Open

Upstart bridge fails when using profiles without autologin #728

RabidArts opened this issue May 14, 2015 · 9 comments

Comments

@RabidArts
Copy link

Hi all

I had this situation with a kodi installation, specifically with profiles set up, and no auto-login.

Kodi would throw an error on startup (onscreen) saying that the xbian upstart bridge script failed.
Following that, a number of other things in kodi are unstable - I would get random reboots.
This is likely due to memory leaks.

I have already fixed the issue on my system, and am contributing the cause and solution to the community.

Investigation:

In the kodi log (~/.kodi/temp/kodi/log) you will find that the upstart bridge script fails on line 119.

Example kodi log error:

ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                         - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                        Error Type: <type 'exceptions.KeyError'>
                                        Error Contents: ('result',)
                                        Traceback (most recent call last):
                                          File "/usr/local/share/kodi/addons/script.service.xbian.upstart-bridge/service.py", line 202, in <module>
                                            service = UpstartBridge()
                                          File "/usr/local/share/kodi/addons/script.service.xbian.upstart-bridge/service.py", line 20, in __init__
                                            self.monitor = XBMCMonitor(self)
                                          File "/usr/local/share/kodi/addons/script.service.xbian.upstart-bridge/service.py", line 120, in __init__
                                            json_version = json_response['result']['version']
                                        KeyError: ('result',)
                                        -->End of Python script error report<--

Looking on line 119 you find the following:

    # This should never fail
    json_response = json.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": "ApiVersion", "method": "JSONRPC.Version"}'))
    json_version = json_response['result']['version']
    self.jsonrpc_api_ver = (json_version['major'], json_version['minor'], json_version['patch'])

If you log the return value from JSONRPC, you'll find that it says 'Method not found'

BTW, the This should never fail comment really cracked me up.
Nice one Anaconda! :D (xbianonpi/xbian-package-upstart-xbmc-bridge@de89836)

*TL;DR: *

Cause:

The JSON RPC service is not started when xbian starts, only once you log in.
If you have multiple profiles, well, you can guess the rest.

Solution:

Change the xbian upstart script to run on login, not on startup.

How, you say?
sudo nano /usr/local/share/kodi/addons/script.service.xbian.upstart-bridge/addon.xml
Find the line with:

     <extension point="xbmc.service" library="service.py" start="startup"/>

Replace start="startup" with start="login"
Save, reboot, celebrate, profit!

Confirmation:

I logged out the response from JSONRPC.Version in the xbian upstart script - result is:
XBian XBMC-Upstart bridge: JSON RPC Version Response: { " i d " : " A p i V e r s i o n " , " j s o n r p c " : " 2 . 0 " , " r e s u l t " : { " v e r s i o n " : { " m a j o r " : 6 , " m i n o r " : 2 1 , " p a t c h " : 2 } } }

RabidArts added a commit to RabidArts/xbian-package-upstart-xbmc-bridge that referenced this issue May 14, 2015
…tup, to fix issues when using profiles with no auto-login

(xbianonpi/xbian#728)
@RabidArts
Copy link
Author

Update:
I'm experiencing a potential side effect of this solution - sometimes I have to log in twice. Possibly a race condition on the upstart script when set to run on login, and some other part of the system.

This doesn't bother me a lot, but obviously a problem for a stable build release.

I'll have a look at the logs and see if I can resolve it or at least get more information.

Possible solutions that come to mind:

  1. Upstart on startup, but delay json rpc calls until login.
  2. Find the script that crashes on login, and make it more resilient by , e,g, waiting and retrying

@Smultie
Copy link

Smultie commented May 18, 2015

I don't use any profiles, and XBian has been throwing me the same error since a couple of updates, but the solution you posted isn't helping in my situation.

Thanks for trying to fix it, though!!

@RabidArts
Copy link
Author

Must be a different reason in your case... Could you link us a pastebin of
your kodi log?
On 18 May 2015 13:29, "Smultie" notifications@github.com wrote:

I don't use any profiles, and XBian has been throwing me the same error
since a couple of updates, but the solution you posted isn't helping in my
situation.

Thanks for trying to fix it, though!!


Reply to this email directly or view it on GitHub
#728 (comment).

@Smultie
Copy link

Smultie commented May 19, 2015

Sure, see below:
http://pastebin.com/iNu0kBAY

@RabidArts
Copy link
Author

Update: Haven't had a chance to look again yet - hope to try looking at it tomorrow.
However in your case (Smultie), I can see the line numbers are a bit different, so as I suspected, it's unlikely to be the same issue.

@RabidArts
Copy link
Author

Smultie:
I had a look at the code to work out where your problem is, but your version of the usptart bridge addon appears to be quite different.
It's either custom-modified or very old - I cannot find your version anywhere online.

My advice - uninstall and reinstall the upstart bridge from the xbian config dialog on ssh login.
But this is just my suggestion as an amateur - use at your own risk :)

@Smultie
Copy link

Smultie commented May 28, 2015

Yeah, might be something I should've told you from the start; I'm running
XBian on Jessie.
http://apt1.xbian.org/pool/stable/rpi2-jessie/ and
http://apt1.xbian.org/pool/staging/rpi2-jessie/

On Thu, May 28, 2015 at 7:10 PM, RabidArts notifications@github.com wrote:

Smultie:
I had a look at the code to work out where your problem is, but your
version of the usptart bridge addon appears to be quite different.
It's either custom-modified or very old - I cannot find your version
anywhere online.

My advice - uninstall and reinstall the upstart bridge from the xbian
config dialog on ssh login.
But this is just my suggestion as an amateur - use at your own risk :)


Reply to this email directly or view it on GitHub
#728 (comment).

@RabidArts
Copy link
Author

Smultie:
I can't seem to find the service.py file for the Jessie version.

Could you start a thread elsewhere (if you haven't already)?
And in it post the content of the
file /usr/local/share/kodi/addons/script.service.xbian.upstart-bridge/service.py

That way I can help advise you based on the actual code, and more
importantly, give other (more knowledgeable) people in the forum a chance
to answer :)

On Thu, May 28, 2015 at 7:19 PM, Smultie notifications@github.com wrote:

Yeah, might be something I should've told you from the start; I'm running
XBian on Jessie.
http://apt1.xbian.org/pool/stable/rpi2-jessie/ and
http://apt1.xbian.org/pool/staging/rpi2-jessie/

On Thu, May 28, 2015 at 7:10 PM, RabidArts notifications@github.com
wrote:

Smultie:
I had a look at the code to work out where your problem is, but your
version of the usptart bridge addon appears to be quite different.
It's either custom-modified or very old - I cannot find your version
anywhere online.

My advice - uninstall and reinstall the upstart bridge from the xbian
config dialog on ssh login.
But this is just my suggestion as an amateur - use at your own risk :)


Reply to this email directly or view it on GitHub
#728 (comment).


Reply to this email directly or view it on GitHub
#728 (comment).

@RabidArts
Copy link
Author

In the pull request, mk01 says : "the needed "initctl emit xbmc-loaded" was moved directly into xbmc code, so non starting of this service (without login - in case of profiles) should not longer be an issue. or ?"

So gonna have a look sometime and try it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants