[android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-29 Thread Robert Green
Dianne, I don't know why but I found that my games were jittery using SystemClock.uptimeMillis(). It's as if there was a little inconsistency and when doing time-interpolated movements, it shows. I've never run a test comparing the output of nanoclock vs uptime so I have no empirical evidence, bu

Re: [android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-29 Thread Dianne Hackborn
Fwiw, we generally use SystemClock.uptimeMillis() in the platform. This is monotonic and should not jump. It does not increment when the CPU is not running, but typically this is actually fine or even good behavior. (For example, it is used to time messages in handlers; if you post a delayed mes

[android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-29 Thread Samsyn
just a little followup.. thanks again Robert for encouraging me to use nanoclock. I eventually got around to the conversion (I had been invoking System.currentMillis in a thousand individual locations, of course :-) Anyway clock sync is better than ever, whether I am on Wifi/3gs or lagging my poot

[android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-12 Thread Samsyn
I admit I have pretty much given up on all the android string formatting, as just being too painfully slow to use during the game itself. I'm actually not using many views any more either, though that's probably just an overreaction on my part. I basically have one view (once the game starts) and

[android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-10 Thread Kaj Bjurman
Have you checked all entried in logcat to see if you can see anything odd? I had e.g. a loop where each iteration did something like: Log.i(TAG, "Forecast expires at " + aJavaDateInstanceRepresentingExpirationDateTime); Each execution of that log statement took about 1-2 seconds since date.toStri

[android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-10 Thread Robert Green
FYI - Good that you're doing it that way. I have to recommend switching to nanoTime, though. I've witnessed multi-second time updates (from the system, not from me) while playing my games and it's not pretty. I've switched everything to nanoTime / 100 since then (which gives milliseconds) an

[android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-10 Thread Samsyn
Thanks, Robert! yes, don't worry, I wasn't doing that. :-) Basically the server has the master time, each client has a dynamic ping value to the server, which is also shared with the other clients for suitable adjustments. at key moments a client notes the local currentMillis() value matching a

[android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-10 Thread Robert Green
Samsyn, For multiplayer synchronization, you absolutely can not count on the current time of either device. Here's one way to handle it: Both host and client use System.nanoTime() / 100; That gives you a fairly accurate counter to use. Host sends snapshots with their current time. Client a

[android-developers] Re: currentTimeMillis() doesnt match on two concurrent emulators

2010-03-10 Thread Samsyn
at the risk of answering my own question (with the to-be-expected accuracy level associated with that), it appears that if I * shut down eclipse * open two CMD windows * launch the emulators from command line that I get much better peformance (5x better?), less 'time-slice- theft' (top window sti