[Testing] X11(simple desktop) + Chromium(web browser) in a simple installer for Stretch

Hi,

Some news from last time :

  • I gave up trying to sleep for less than 30sec
  • After the fbset I didn’t tweak anything more,
  • Since then I’ve been repeatedtly (more than daily) launching the browser, closing it and going back to kodi, etc. without any reboot. No problem occured whatsoever so I guess I’m pretty stable now :). (using 1280x720 btw, for more char readability)

Actually I also thought that instead of using sleep we may also modify the .rc scripts and trigger a reboot and maybe make the transition faster, but I’m not sure. (the reboot phase seems pretty fast on the pi 3)

Last thing (but I think this doesn’t belong on this thread) : The pi emits a constant whistle when I’m on a SABNZBD page (the sabnzbd is installed on my synology NAS). I could check hat th whistle didn’t come from the TV audio (with TV muted it’s all the same) so I wonder what it could be …

@Beignet10 Less then 30 sec is hard, i got it down to 27, but i depends how long time it takes for kodi to close down. That in turn depends on plugins installed etc. 27 sec was with a clean install on a pi2.

Glad you got it to work in 1280x720, did you set it with fbset before X started or edited X-config files or did you set kodi resolution to 1280x720?

I did a try with haveing X running in the background of kodi, but it didn’t change that much of launch time.

I used fbset before X. (there was also an option in chromium to choose resolution, but maybe it wasn’t useful)

Abuse the sigterm handler I added to Kodi and you will probably get the Kodi shutdown time to a couple of seconds.

thanks, used systemctl stop mediacenter, but if sigterm is quicker and “not to dirty”

got the sleep down to about 12,
doing “sudo systemctl stop mediacenter & sudo pkill kodi” if i just used pkill kodi, i got sadface and restart of medicenter.

sigterm will save guisettings and exit nicely, but it makes some shortcuts with cec destruction and killing of add-ons (it does not wait for them).

The typical shutdown process is:

  • User chooses Shutdown
  • This calls g_Application quit routines and sends a shutdown signal via logind
  • systemd catches logind signal
  • systemd sends signal and waits for Kodi gracefully. If no joy in 30secs, it kills it.

Sam

It would be great to get kodi to shutdown in a couple of seconds.

@joakim_s is there way to test the method sam mentions.

Where do i put the “sudo systemctl stop mediacenter & sudo pkill kodi” command. Do i have to change the sleep duration in x_init.sh using this command.

Thanks again

@the_bo here are the start files:

xstart.sh:
> #!/bin/bash
> sudo openvt -c 7 -s -f clear
> sudo su osmc -c “nohup openvt -c 7 -f -s /home/osmc/x11-start/x_init.sh &” &
> sleep 2
> sudo su -c “sudo systemctl stop mediacenter & sudo pkill kodi.bin” &
> exit

x_init.sh
> #!/bin/bash
> sleep 12
> sudo openvt -c 7 -s -f clear
> sudo su osmc -c “startx”
> sudo openvt -c 7 -s -f clear
> sudo systemctl start mediacenter
> exit

If you run X in the background, like i tried you get about 2 secs off (the time it takes to start X, but you have to login to X instead.)

Thanks joakim ill give them a test

If you run X in the background

Does this mean leaving x11 running in background while going back to kodi instead of using logout option?

cheers

X is started before kodi and lays dormant in the background (eating a bit of RAM) and when you start the launcher it still takes 10-12 sec’s to close kodi, and instead of those seconds starting X you get a login screen. I think it isn’t worth saving 2-4 seconds, just to lose RAM and still have to login every time you launch X from kodi.

Don’t remember how it was to exit, might give it a try again later.

Got black screen issues using

xstart.sh:

sudo openvt -c 7 -s -f clear
sudo su osmc -c “nohup openvt -c 7 -f -s /home/osmc/x11-start/x_init.sh &” &
sleep 2
sudo su -c “sudo systemctl stop mediacenter & sudo pkill kodi.bin” &
exit

x_init.sh

sleep 12
sudo openvt -c 7 -s -f clear
sudo su osmc -c “startx”
sudo openvt -c 7 -s -f clear
sudo systemctl start mediacenter
exit

Tried increasing sleep. Just went back to sleep 40 which worked previously. I dont mind the waiting its just that if i have a shortcut on my skin to x11 launcher it doesnt display a “please wait buffering” like it does if run it from programs menu.

No worries though grateful to have a browser on pi thanks :slight_smile:

Did you try testing sams sigterm method by any chance.

Cheers

@the_bo strange, the “sudo pkill kodi.bin” part sends a sigterm to kodi process. It changed my kodi close down time from 25-26 secs to 10-11 secs. which in turn made it possible to have just sleep 12.

If you want to try to cut the sleep, check how many seconds that passes between you launch from kodi till you get the black screen with a white underscore. The time it takes from “black screen” till X started you can cut from sleep. That way can you trim the seconds.

Don’t know anything about skins or kodi “magic”, I’m using Confluense, since the mrs learned how to navigate it back when i ran a hp laptop as media center. So i’m sorry cant help you there.

Looking at Git, in particular:

https://github.com/osmc/osmc/blob/master/package/mediacenter-osmc/patches/all-013-Do-not-try-and-stop-scripts-if-we-are-going-to-reboot.patch

I don’t think SIGTERM sent directly will help. You would have needed to try and reboot the device first. Looking again, we save a chunk of time by only calling CScriptInvocationManager::GetInstance().Uninitialize(); if the user has selected ‘Exit’ and not shutdown:

if (m_ExitCode == EXITCODE_QUIT)
      CScriptInvocationManager::GetInstance().Uninitialize();

m_ShuttingDown is only set on TMSG_RESET or TMSG_RESTART. If @joakim_s’s project picks up, we can look at exposing the quicker shutdown via JSON-RPC. Otherwise, with a quick glance, I wouldn’t expect to see a speedup via sigterm.

Sam

@sam_nazarko Most of that went over my head.

Something you said about reboot made me check, first time I launch after reboot kodi shut down take longer then 10 secs, ending with a black screen. But if i restart mediacenter again, sshing in and running sudo systemctl start mediacenter. Kodi comes back up, and the fun part is, if I launch x11 again it just takes 12 seconds.

Now i guess you figured as much, but for me it is “magic”

Edit: In short is there a way to trigger an “exit” from bash right now, or is that something you have to add to the code?

What you actually want to do is trigger a fake reboot, or set m_ShuttingDown. This is not yet possible from command line. Maybe I will add a quick way of doing it for quicker updates etc and you can use it then. I will let you know.

Edit: we can probably handle it in SIGTERM and follow quit routines but with a bool like ‘b_quickExit’.

gonna try this, “xbmc-send -a “Quit” | sudo systemctl stop mediacenter” insted of pkill. See if i get it to work after a reboot aswell.

@the_bo ypu might wanna try to change your xstart.sh aswell.

But Quit is not going to make it work. Look at the patches and you will see that we only wait for add-ons to finish iff we are sending quit.

You also have no guarantee xbmc-send will work (JSON-RPC may be disabled). But better than nothing.

I will make it possible soon.

Thanks Sam. I’ll keep this version for now since at least this version works after reboot, i get it to constant shutdown under 12 secs. But as you said, JSON-RPC may be disabled.

It’s quick, but it’s not as quick as it can be :wink:

Currently, the time taken to shut down is dependent on # of (and quality) of add-ons installed. In the future it will not be.

Just installed retrosmc and it boots into retropie in a few seconds.

@joakim_s maybe @mcobit might have some tips on how retrosmc works with kodi shutdown.

Would it be possible maybe to display a splash screen of some sort when launching x11 while waiting for kodi to shutdown in background. Would be a nice transition during the wait inside of having the please wait dialogue.