Skip to content

Commit 80f7580

Browse files
committed
Increase event timeStamp resolution
Depends on lightpanda-io/libdom#36 The spec says this should be a High Definition timestamp. But browsers avoid that in order to avoid fingerprinting. By default, FireFox rounds to 2ms (which is what this PR does). Previously, the timestamp was seconds, so you'd think: isn't that better? Well, it's pretty far off the spec and what browsers do, but more importantly, it crashes our WPT test. If you look at `Event-timestamp-safe-resolution.html` you'll see that it's trying to find the delta between two timestamps, in an endless loop (without a loop of many iterations). With second-resolution, it just takes too long (and crashes..memory).
1 parent b5e2c62 commit 80f7580

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/browser/events/event.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub const Event = struct {
113113
// Even though this is supposed to to provide microsecond resolution, browser
114114
// return coarser values to protect against fingerprinting. libdom returns
115115
// seconds, which is good enough.
116-
pub fn get_timeStamp(self: *parser.Event) !u32 {
116+
pub fn get_timeStamp(self: *parser.Event) !u64 {
117117
return parser.eventTimestamp(self);
118118
}
119119

src/browser/netsurf.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,11 @@ pub fn eventIsTrusted(evt: *Event) !bool {
505505
return res;
506506
}
507507

508-
pub fn eventTimestamp(evt: *Event) !u32 {
509-
var ts: c_uint = undefined;
508+
pub fn eventTimestamp(evt: *Event) !u64 {
509+
var ts: u64 = 0;
510510
const err = c._dom_event_get_timestamp(evt, &ts);
511511
try DOMErr(err);
512-
return @as(u32, @intCast(ts));
512+
return ts;
513513
}
514514

515515
pub fn eventStopPropagation(evt: *Event) !void {

0 commit comments

Comments
 (0)