Bug 17164 - Clock runs slow using internal SB touch server
: Clock runs slow using internal SB touch server
Status: RESOLVED WONTFIX
Product: SB Touch
Classification: Unclassified
Component: TinySC
: 7.7.1
: All All
: -- normal with 26 votes (vote)
: 7.6.x
Assigned To: Alan Young
: alarm_related, radioAlarmsCritical
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-20 02:20 UTC by tobias
Modified: 2019-01-25 10:11 UTC (History)
7 users (show)

See Also:
Category: ---


Attachments
Proposed patch (912 bytes, patch)
2011-08-28 07:17 UTC, Alan Young
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tobias 2011-04-20 02:20:29 UTC
I am using the built in SB server with an USB harddrive. On boot the SB Touch fetches the correct time from the Internet, but the clock is running slow. Within a week the clock differs by two minutes. Restarting leads to the correct time, sshing onto the Touch and using ntp also works. 

If there were cron-support I could use it to automatically set the time daily, but without this is not easy. 

I have several other SBs including SB Radio next to my bed as an alarm clock. It is really annoying that this expensive piece of hardware is unable to display the correct time.
Comment 1 Nicolas 2011-05-02 09:41:01 UTC
Same problem with 7.6 beta.

see thread http://forums.slimdevices.com/showthread.php?t=87431
Comment 2 Nicolas 2011-05-02 09:43:22 UTC
I guess that a function to manually set date/time is anyway mandatory in the settings menu.

If you use the Touch with TinySBS in a location with no PC and no internet access, you have to be able to manually set data/time

see thread http://forums.slimdevices.com/showthread.php?t=87431
Comment 3 tobias 2011-05-02 10:56:12 UTC
That's right, manual setting of time is also a must have, especially for offline usage.

But please do not make this the only possibility. It's an internet device that is capable of receiving the correct time. So please run this functionality once a day without user-interaction.
Comment 4 Nicholas 2011-05-03 06:36:56 UTC
When my Squeezebox Touch is using the SD card library it looses a minute or so per day.  To keep the time correct I daily "Switch to mysqueezebox.com" and then "Switch to library: Touch(SD)".  7.5.4
Comment 5 Phil 2011-05-05 08:49:19 UTC
*** This bug has been confirmed by popular vote. ***
Comment 6 Jean Tourrilhes 2011-05-07 23:29:40 UTC
I'm using TinySB. I've personally seen two modes.

Most often, the Touch get the proper time a boot, but it drifts quite quickly. After two weeks, it's a few minutes off, which is not acceptable. The radio that is connected to TinySB keep sync with the Touch, which means it drifts as well.

Some time, the Touch does not get any time at all at boot. In this case, the off screen remains totally black and the screensaver does not kick in, both on the Touch and on the Radio. Note that since the update to 7.5.4, it's currently in this state.

I've had the Touch since april 2010, and I've never seen it keeping time properly, except maybe the very first month, but maybe I was not paying attention.

I was planning to buy another Radio or a Boom2 as an alarm clock, but that does not seem like a great plan. I'm using NTP on my computers so I know that having accurate time using the Internet is possible.

Jean
Comment 7 Jean Tourrilhes 2011-05-08 23:50:59 UTC
There is probably various ways to "fix" the current setup, but it will never be as reliable and accurate as NTP. So, I would personally vote to get NTP on the Touch and get rid of the current scheme.

See : http://forums.slimdevices.com/showthread.php?t=87588

Jean
Comment 8 tobias 2011-08-27 05:03:06 UTC
New SW-version but still the same problem.
What can I do to make this issue receive more attention?
Comment 9 David Gardner 2011-08-27 14:58:28 UTC
(In reply to comment #8)
> New SW-version but still the same problem.
> What can I do to make this issue receive more attention?

I confirm - still in 7.6.1. I really thought this was fixed in 7.6. Must surely be trivial for someone who knows the code.
Comment 10 Alan Young 2011-08-28 07:08:33 UTC
There is a mechanism that resyncs the time every 3600 seconds. I can see a way that this would fail. Experimental evidence seems to confirm this. The relevant code fragment is:

	if ( $snTime && $snTime =~ /^\d+$/ && $snTime > 1262887372 ) {
		main::INFOLOG && $log->info("Got SqueezeNetwork server time - set local time to $snTime");
		
		# update offset to SN time
		$prefs->set( sn_timediff => $snTime - time() );
		
		# set local time to mysqueezebox.com's epochtime 
		Slim::Control::Request::executeRequest(undef, ['date', "set:$snTime"]);	
	}
	else {
		$log->error("Invalid or no mysqueezebox.com server timestamp - ignoring");
	}

	Slim::Utils::Timers::killTimers( undef, \&syncSNTime );
	Slim::Utils::Timers::setTimer(
		undef,
		time() + SNTIME_POLL_INTERVAL,
		\&syncSNTime,
	);

This will actually update the system clock in two ways:
1. via the preferences on-change handler for sn_timediff in Slim::Utils::OS::SqueezeOS;
2. via the 'date' request with the 'set' parameter (if and only if the Touch UI is controlling a player using the Touch's own server - the usual case).

The problem is that the Slim::Utils::Timers::setTimer call (actually Slim::Utils::Timers::_makeTimer()) uses EV::now as the reference time which will, by now, be out of date because of the updated time. In the common case that the Touch's initial time will be the Unix epoch, the result is that the next time update will not happen for something over 40 years (at the time of writing).

I guess that the Timers module needs a means to be notified that the system clock has been updated and this should be called by Slim::Utils::OS::SqueezeOS::settimeofday().
Comment 11 Alan Young 2011-08-28 07:17:51 UTC
Created attachment 7434 [details]
Proposed patch
Comment 12 SVN Bot 2011-09-07 06:42:55 UTC
 == Auto-comment from SVN commit #33320 to the slim repo by ayoung ==
 == http://svn.slimdevices.com/slim?view=revision&revision=33320 ==

Fixed bug 17164: Clock runs slow using internal SB touch server 
Notifiy Timers subsystem of epoch change so that new timers in same interval get correct interval.
Comment 13 SVN Bot 2011-09-07 07:35:14 UTC
 == Auto-comment from SVN commit #33322 to the slim repo by ayoung ==
 == http://svn.slimdevices.com/slim?view=revision&revision=33322 ==

bug 17164: Clock runs slow using internal SB touch server
Comment 14 tobias 2011-11-12 10:23:12 UTC
Updated to 7.7.0 r33614, still the same problem: Several minutes running slow within a week. :-(
Comment 15 Tomas 2011-11-17 11:22:36 UTC
(In reply to comment #14)
> Updated to 7.7.0 r33614, still the same problem: Several minutes running slow
> within a week. :-(

I confirm the problem. I'm running Squeezebox Touch 7.7.0 r9550 with 32GB USB stick with music. 
Uptime is 7 days & 21 hours and clock is delayed by 4 muntes.
Tomas
Comment 16 Alan Young 2011-11-18 00:10:43 UTC
Can you confirm that your Touch can talk to mysqueezebox.com properly and that you have done nothing to inhibit this functionality. For example, does the My Apps menu display appropriate items?
Comment 17 Mikael Nyberg 2011-11-18 08:03:50 UTC
*cought*

 http://forums.slimdevices.com/showthread.php?t=87588&highlight=ntp

Why not implement ntp and be done with it ?
Comment 18 tobias 2011-11-19 14:30:27 UTC
(In reply to comment #16)
> Can you confirm that your Touch can talk to mysqueezebox.com properly and that
> you have done nothing to inhibit this functionality. For example, does the My
> Apps menu display appropriate items?

Switching the music source to mysqueezebox.com works - and syncs the time. But if I switch back to the internal music server, the clock starts running slow again.

Also:
- no firewall or other connectivity affecting devices
- plugged directly into AVM Fritz!Box via cat 5 ethernet cable
- "My Apps" works
- connectivity test works
- it did not stop working, it never worked before. There are only two types of devices in my home that need a manual time adjustment: a 50 euro microwave and my Squeezeboxes (2 x Radio, 1 x Touch, 1 x Controller) :-(

PS: I made you guys a couple of photos - please notice that the wrist watch in one of the pictures is radio controlled (DCF77)
http://www.dropbox.com/gallery/2251582/1/Squeezebox?h=e23caa
Comment 19 Mikael Nyberg 2011-11-27 04:14:00 UTC
(In reply to comment #16)
> Can you confirm that your Touch can talk to mysqueezebox.com properly and that
> you have done nothing to inhibit this functionality. For example, does the My
> Apps menu display appropriate items?

Look in the linked tread Toby10 did a test.

What is broken is as the bug title suggest, when running the built in server against a media it never checks with mysb.com for time adjustments it just don't even if the connection is working.
Comment 20 Michael Herger 2011-11-27 22:24:43 UTC
could you please check your device's log file when you're seeing this drift? Log in using ssh and check /var/log/messages.

If you're not familiar with ssh, go to Settings/Advanced/Sharing/USB Storage/Sharing: enable it and you should be able to access the log through Windows networking.

Failure to sync the time should be logged.
Comment 21 tobias 2011-11-29 14:03:42 UTC
(In reply to comment #20)
> could you please check your device's log file when you're seeing this drift?
> Log in using ssh and check /var/log/messages.

Logfile on Dropbox:
http://db.tt/ZUMqJe6b

Yesterday night TinySC crashed while being in standby so the clock is quite acurate today.
Comment 22 Nicholas 2011-12-08 10:07:22 UTC
Squeezebox Touch connected to the SD card. 7.7.0.  Still loosing time.
Comment 23 tobias 2011-12-21 12:47:17 UTC
7.7.1 - clock still behind :-(
Comment 24 Nicholas 2011-12-24 08:16:25 UTC
(In reply to comment #22)
> Squeezebox Touch connected to the SD card. 7.7.0.  Still loosing time.

Squeezebox Touch connected to the SD card. 7.7.1.  Still loosing time.
Comment 25 Nicolas 2012-01-09 03:08:16 UTC
Touch connected to USB Stick.
Same problem still here with 7.7.1

Is somebody working on this (bug is marked as assigned) ?
Basic problem reported 9 monthes ago ...
Comment 26 tobias 2012-01-10 05:36:06 UTC
(In reply to comment #25)
> Is somebody working on this (bug is marked as assigned) ?

I don't think so. :-(

> Basic problem reported 9 monthes ago ...

This is really a pain in the ass, what could I do to give this bug more attention?
Comment 27 Tomas 2012-01-10 11:59:33 UTC
(In reply to comment #25)
> Touch connected to USB Stick.
> Same problem still here with 7.7.1
> 
> Is somebody working on this (bug is marked as assigned) ?
> Basic problem reported 9 monthes ago ...

Squeezebox Touch with USB stick; running SB server on Touch. Firmware 7.7.1
Uptime 9days + 2hours - time delayed by 50 seconds
It would be great to have the issue fixed in the next version.
Tomas
Comment 28 Dan 2012-01-23 11:53:40 UTC
When using the TinySC built into the touch and using an external drive the touch loses time within a few days.  This affects all devices downstream connecting through the touch.  Using the alarm from a squeezebox radio connected through the touch becomes unreliable within a few days and defaults to the backup alarm.  Time gets reset when connecting the touch to mysqueezebox.com.  I have temporarily left the touch contacted to mysqueezebox.com but left the internal tinySC running so the Squeezebox radio still connects through the touch.  The time issue goes away and I'm still able to access my files, but I must manually change the touch back to the tinySC when playing local files using the touch.  Please fix ASAP!  Thanks!
Comment 29 Alan Braslau 2012-02-08 00:16:06 UTC
(In reply to comment #28)
> When using the TinySC built into the touch and using an external drive the
> touch loses time within a few days.  This affects all devices downstream
> connecting through the touch.  Using the alarm from a squeezebox radio
> connected through the touch becomes unreliable within a few days and defaults
> to the backup alarm.  Time gets reset when connecting the touch to
> mysqueezebox.com.  I have temporarily left the touch contacted to
> mysqueezebox.com but left the internal tinySC running so the Squeezebox radio
> still connects through the touch.  The time issue goes away and I'm still able
> to access my files, but I must manually change the touch back to the tinySC
> when playing local files using the touch.  Please fix ASAP!  Thanks!

When using TinySC, the clock does not appear to be properly reset even on reboot,
and, of course, internet is connected... This is very annoying.

A solution using ntpclient has been proposed:
http://forums.slimdevices.com/showthread.php?t=87588

This seams to work well (I did not compile ntpclient, but used the [second] provided tar image). It is a temporary fix, as I will have to re-install on my Touch(s) whenever the system gets updated. Logitech should include this by default (or some other solution that works). If ntpclient is adopted, of course the user would need to be able to configure the choice of ntp server by menu.

Alan
Comment 30 Nicholas 2013-01-01 17:43:26 UTC
Slow clock problem still not resolved. 7.7.2
Comment 31 Michael Herger 2019-01-25 10:11:12 UTC
TinySC will not be updated any more.