Linux' system time change and Wait()

Discuss any general programming issues here
Post Reply
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Linux' system time change and Wait()

Post by Flinx »

Hi

My current project of a music player with lyrics runs on a Raspberry Pi which has a read-only operating system so that you can turn off the device without shutting it down. And the device has network access.
Since the Raspberry does not have a battery-backed clock, it runs with an old system time for a while after startup. After a few minutes it sets the clock.
This caused strange effects in my program, which are caused by the fact that the Hollywood timers seem to depend on the system time. If the date makes a jump from 1/28/2022 to 3/8/2022, the timer that runs continuously from the beginning has then a value about -901000000.
I have fixed most of the effects in the meantime with workarounds, only the running music reports a wrong position (and so the displayed text is out of sync), for which I have not found a fix. But with the next music it is correct again.

In the program Wait() is also used in some places. My question now is: Do I have to expect effects with Wait as well? I have tried and my experiments say no, but I better ask.

Ralf
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Linux' system time change and Wait()

Post by airsoftsoftwair »

No, Wait() is safe. It is implemented in a different way than the timers. But the fact that timers are dependent on the system clock on Linux/macOS/Android/iOS is definitely a bug that must be fixed. Thanks for reporting, I'll fix this!
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Linux' system time change and Wait()

Post by airsoftsoftwair »

Code: Select all

- Fix [Linux/Android]: Timer functions are now independent of the system clock, i.e. they will never return
  spurious values in case the system clock changes while the script is running
Post Reply