Proposal: Change all timestamps to int64_t micro seconds
For historical reasons all the timestamps in mutter and gnome-shell are 32 bit unsigned integers with millisecond granularity. The reason for this I assume is because this is the timestamps used by X11. However, using millisecond granularity and an unsigned 32 bit integer has significant flaws, most notably the fact that it overflows every ~49 days.
What this means in practice is that when your uptime reaches around 49 days, old timestamps will appear as if they are newer than old ones. A visible bug this results in is the window list in the window/app switcher will be incorrect.
Parts of both mutter and gnome-shell already use 64 bit integer with microsecond granularity, for example input events from libinput, or anything frame scheduling related. What I propose is to change everything else, i.e. timelines, events, user activity time, focus time, and all other window management related timestamps as well.
Timestamps from X11 would be converted by maintaining an offset to the monotonic clock (which we already do), and be simply casted down to unsigned 32 bit integers before being sent of to X11 land.
Other ideas of how to solve these issues have been floating around, for example passing an "era" number together with relevant timestamps, where the era increases every overflow, but I think just switching to a timestamp data storage and format that will just handle things indirectly is a much nicer solution.
What would this need?
-
Wrap every timestamp that comes from or to X11 in a conversion function. -
Switch all API to use int64_t
microseconds instead ofuint32_t
milliseconds-
Cogl -
Clutter -
Mutter
-
-
Port gnome-shell -
Port gnome-shell-extensions