[SOLVED] very strange startup issue

Post your Gambas programming questions here.
Post Reply
User avatar
sadams54
Posts: 143
Joined: Monday 9th July 2018 3:43am
Contact:

[SOLVED] very strange startup issue

Post by sadams54 »

This problem is strange. I am using fedora 36,37 and I am attempting to have a gambas written program come up at system start up/sign in. Some computers work flawlessly, others will not start the gambas written program. Now on one of the offending computers I have 2 gambas programs for startup. one of the programs starts without issue the other always fails. The program that starts always on this one will fail to start 50% of the time on another PC. I have not been able to figure out a pattern or why the programs fail at system start. They run if I select them without issue. I am hoping somebody here can point me towards something I have not thought of.
Last edited by sadams54 on Monday 9th October 2023 11:34pm, edited 1 time in total.
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: very strange startup issue

Post by BruceSteers »

did you set a startup delay?

this is how my $HOME/.config/autostart/Desktop-ish.desktop file looks...

Code: Select all

[Desktop Entry]
Type=Application
Exec=/media/bonus/SSDiskspace/git/Desktop-ish/Desktop-ish.gambas
Hidden=false
Name=Desktop-ish
X-MATE-Autostart-Enabled=true
X-MATE-Autostart-Delay=3
X-GNOME-Autostart-Enabled=true
X-GNOME-Autostart-Delay=3
Sometimes a gambas application can start before all it's requirements have loaded (like the system tray for example)

By adding a delay it allows the other things to load first.

It's likely your programs have different requirements and for the one that usually starts they are usually already loaded but for the other they are not.

My X-MATE-Autostart-Delay seems to work at 3 seconds, you might need more on a slower machine like a Pi.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: very strange startup issue

Post by BruceSteers »

Or you can add code to wait for the programs dependencies to load.

For example here is how one of my programs waits untill the Systray has loaded before it continues...


Public Sub _new()

  Dim bHasTray As Boolean, iRetries As Integer

  bHasTray = Desktop.HasSystemTray  ' check systray is loaded

  If Not bHasTray Then  ' if not then wait up to 60 seconds re-checking for systray every second.

    For c As Integer = 1 To 60
      Wait 1
      Inc iRetries
      bHasTray = Desktop.HasSystemTray
      If bHasTray Then Break
    Next
  Endif

  If bHasTray then
    Print "SystemTray is loaded after " & iRetries & " retries"
  Else
    Message.Error("SystemTray not found")
    Quit
  Endif

End

If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1127
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: very strange startup issue

Post by cogier »

I agree with Bruce, you need to delay the start of your program by a few seconds. I have a music program, MelodyBox, I wrote in Gambas (with extra features by Bruce) that needs a few seconds before starting it. This is easy in Linux Mint as there is a Startup Applications program that does the work.

Image
User avatar
sadams54
Posts: 143
Joined: Monday 9th July 2018 3:43am
Contact:

Re: very strange startup issue

Post by sadams54 »

I am going to try the desktop file edit. I had never seen it done that way. I used gnome-tweak-tool to do the autostart and it does not provide for delay.

the options you provided do not work for me at all. They are ignored. I had to modify the exec line instead

Exec=bash -c "sleep 7 && myapp" seems to function as expected. Will let you know if the solution holds up.

so far day 2 and it is holding up. it's alive
Post Reply