[win32] Morphic event timeStamp bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[win32] Morphic event timeStamp bug

marcel.taeumel (old)
Hi!

We identified a bug concerning either the #timeStamp in MorphicEvent objects or Time >> #millisecondClockValue.

Inspecting the result of "ActiveEvent timeStamp - Time millisecondClockValue" returns a suspiciously high number. 21373801 on my last try.

So, the primitive 135, which is used for #millisecondClockValue, points (cointerp.c) to ioMSecs(). For Windows this is "GetTickCount() &0x3FFFFFFF;" (sqWin32Time.C).

Then, the keyboard event (here: CMD+P) gets its timeStamp assigned from the MSG structure in sqWin32Window.c, which is good:

int recordKeyboardEvent(MSG *msg) {
...
evt->timeStamp = msg->time;
...
}

((( Only for drag/drop events into the VM, it uses ioMicroMSecs() [cointerp.c], which is timeGetTime() and has a higher accuracy. )))

The MSDN says this:
MSG structure https://msdn.microsoft.com/en-us/library/windows/desktop/ms644958%28v=vs.85%29.aspx
GetTickCount() https://msdn.microsoft.com/en-us/library/windows/desktop/ms724408%28v=vs.85%29.aspx
GetMessageTime() https://msdn.microsoft.com/en-us/library/windows/desktop/ms644939%28v=vs.85%29.aspx

And some interesting discussions about msg->time vs. GetMessageTime() : http://blogs.msdn.com/b/oldnewthing/archive/2014/01/22/10491576.aspx

Some ideas/questions:

- Why isn't the MillisecondClockMask applied to the message time as in sqMacUIEvents.c ?
- Hmmmm....

Best,
Marcel & Bert
Reply | Threaded
Open this post in threaded view
|

Re: [win32] Morphic event timeStamp bug

marcel.taeumel (old)
Well, it seems that either GetTickCount() does not return the time elapsed since system - not process - start, or that the Windows CogVM does use another version of ioMSecs(), which I cannot spot in the sources.

This, I found in sqWin32Time.c:

int ioMSecs()
{
  /* Make sure the value fits into Squeak SmallIntegers */
#ifndef _WIN32_WCE
  return timeGetTime() & 0x3FFFFFFF;
#else
  return GetTickCount() &0x3FFFFFFF;
#endif
}

There also is a function declaration in sq.h:

sqInt ioMSecs(void);

But I cannot spot the default definition/macro as the comment says:

"
...
By default, the basic ioMSec() clock function is defined
   here as a macro based on the standard C library function clock().
..."

Maybe the comment is outdated... or my sources. :D

Is there a difference between sqInt and int?

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: [win32] Morphic event timeStamp bug

marcel.taeumel (old)
Mea culpa. Of course, it's an "ndef" and thus the VM should use timeGetTime() under Win32.

https://msdn.microsoft.com/de-de/library/windows/desktop/dd757629%28v=vs.85%29.aspx

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: [win32] Morphic event timeStamp bug

marcel.taeumel (old)
Okay, it seems that the Win32 build of CogVM uses clock() from time.h. Because this function returns the time since process start -- not system start.

Events, however, get their timeStamp from the MSG structure, which is correct.

Why does this happen? Eliot? =D

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: [win32] Morphic event timeStamp bug

marcel.taeumel (old)
Okay, I got confused with the sqWin32Time.c, which is of no use for the StackVMs.

However, here is a fix. But I am not sure, whether baseTick or vmThreadBaseTick are the offests to use.

sqWin32Heartbeat.h
sqWin32Heartbeat.c
sqWin32Window.c

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: [win32] Morphic event timeStamp bug

marcel.taeumel
Ahh, I messed it up for the recordDragDropEvent(..). That time was correct.

Eliot, could you check that fix for me, add the proper guards for the non-stack VM (in sqWin32Time.c) and add it to the VM? Pleeeeaaaase? ^___^

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: [win32] Morphic event timeStamp bug

marcel.taeumel
*bump*

Still broken in the recent CogVMs.

Best,
Marcel