use async delivery for buffered performance observer entries

Per spec, buffered entries should be delivered via a queued task,
not synchronously. Extract scheduling logic into
schedulePerformanceObserverDelivery() and use it from both
notifyPerformanceObservers and the buffered observe path.
This commit is contained in:
egrs
2026-02-17 18:16:42 +01:00
parent df9779ec59
commit ca9e2200da
2 changed files with 7 additions and 1 deletions

View File

@@ -1243,6 +1243,11 @@ pub fn notifyPerformanceObservers(self: *Page, entry: *Performance.Entry) !void
}
}
try self.schedulePerformanceObserverDelivery();
}
/// Schedules async delivery of buffered performance observer records.
pub fn schedulePerformanceObserverDelivery(self: *Page) !void {
// Already scheduled.
if (self._performance_delivery_scheduled) {
return;

View File

@@ -116,6 +116,7 @@ pub fn observe(
// Deliver existing entries if buffered option is set.
// Per spec, buffered is only valid with the type option, not entryTypes.
// Delivery is async via a queued task, not synchronous.
if (options.buffered and options.type != null) {
for (page.window._performance._entries.items) |entry| {
if (self.interested(entry)) {
@@ -123,7 +124,7 @@ pub fn observe(
}
}
if (self.hasRecords()) {
try self.dispatch(page);
try page.schedulePerformanceObserverDelivery();
}
}
}