PhotonMessageInfo.timestamp Broken

Hello, I recently started using Photon and ran into a troubling error with my interpolation script. I did a simple test which seems to indicate that something is seriously wrong with the timestamp given from the OnPhotonSerializeView:
function OnPhotonSerializeView(stream : PhotonStream, info : PhotonMessageInfo) {
	if (stream.isWriting) {
   		m = PhotonNetwork.time;
	} else {
		m = stream.ReceiveNext();
		Debug.Log(PhotonNetwork.time + "   |   " + m + "   |   " + info.timestamp);

The debug returned "2473561.088 | 2473560.576 | -1821407" with the info.timestamp value increasing by one each second. Can anyone shed some light as to why the timestamp value is negative?


  • The cause for this is that we're sending timestamps as 4 bytes only. As the time is in each package, this saves some bandwidth.
    Depending on how you interpret numbers, they could be unsigned or signed. If they are considered signed, the first bit of a number is the sign-bit. If that's set, the number is negative.
    As we measure time in milliseconds, all bits of the 4 bytes will be set after a while and that's what happens here.
    Even PhotonNetwork.time is just a 4 bytes number. In the code for it, you can see how we convert our internal milisecond-based value to the double you know from Unity.

    I will have to verify with your code but with that, you should be able to convert your negative value to those you know, until we fix this.
  • Tobias,

    I posted the exact same issue yesterday with a complete debug report demonstrating that most datatypes still generates the error as of PUN 1.7. As soon as the PhotonMessageInfo arrives in the OnPhotonSerializeView() method, it has already lost its precision/turned negative. You can see my latest post here:
    and my complete NetworkSync.cs C# script here (lines 50-80):

    Finally, I must admit I am starting to feel frustrated with the support. I've asked three(3) questions on this forum, each of which I've spent time trying, reading docs, debugging and formulating them clearly. All of my questions have been left aside, except for the user dreamora, who actually tried helping me. I've pointed to you that the website has erroneous documentation for Photon v3 and two months later, it still has not been fixed. I'm not angry and I realize you guys work hard to update the Photon products, but the fact is I'm the only programmer of a small studio and my best friend learning to use Photon is my decompiler, not the official documentation. I feel left aside, what did I do wrong, heh? :|

    As I keep saying, I might be the problem; I'm not the best out there, but I'd appreciate an answer. Thanks!
  • Hm. What should I say?
    First off: I'm sorry your questions didn't get answers by us directly. We try to keep up with everyone here in general but it's not always possible (as you can see). Sometimes we just need a few days, in a few cases a topic is not re-visited by us.
    On the other hand, this is also free support for everyone. We have to keep a balance between helping and doing stuff that pays our bills, so we're pretty happy when you devs help each other.
    Thanks for baring with us and that you insisted this gets fixed.

    The solution is simple: Treat PhotonMessageInfo.timestamp like PhotonNetwork.time.
    Internally, timestamp uses timeInt, which is said 4-bytes timestamp. Modify the getter for PhotonMessageInfo.timestamp like this:
    public double timestamp
        get { return (uint)timeInt / 1000.0f; }
    public override string ToString()
        return string.Format("[PhotonMessageInfo: player='{1}' timestamp={0}]", this.timestamp, this.sender);

    This gives me:
    PhotonNetwork.time: 2497907.456 msgInfo: [PhotonMessageInfo: player='Guest7682' timestamp=2497907.456] timestamp: 2497907.456

    This will be fixed in the next PUN version (probably v1.7.1).
  • My long explanation has been erased by the browser reload so I'll keep it short:

    Well that's shameful... Thanks for the fast and helpful answer, turns out your solution solves the issue. I didn't notice the PhotonMessageInfo class anywhere and believe it was part of the PUN library :oops: . I guess I should apologize for acting like a child and needing attention so much, my bad. I really do appreciate the constant effort ExitGames is putting into updating the Photon products.

    So I'll stick around; Photon is actually quite simple and powerful, but only once one has gathered all the docs and made himself some kind of custom interface. I'm actually working on this for myself and eventually other newbies like me that are daunted by all the concepts. It won't do any good to experienced developers but I bet I'm not the only one confused with simple stuff and a UnityPackage would probably help beginners like me to understand. I've based it off PUN1.7 and logged every single modifications I've made to the package, it should be ready pretty soon.

    Perhaps keeping a few beginners out of the forums will give you guys more free time to write down the V3 documentation ;) !
  • Glad to read this helped you. Don't worry about "needing attention" or such. Sometimes you have to vent.
    Don't hesitate to ask. If nothing else, we might get bored answering by posts and write docs ;)