mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
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:
@@ -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.
|
// Already scheduled.
|
||||||
if (self._performance_delivery_scheduled) {
|
if (self._performance_delivery_scheduled) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ pub fn observe(
|
|||||||
|
|
||||||
// Deliver existing entries if buffered option is set.
|
// Deliver existing entries if buffered option is set.
|
||||||
// Per spec, buffered is only valid with the type option, not entryTypes.
|
// 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) {
|
if (options.buffered and options.type != null) {
|
||||||
for (page.window._performance._entries.items) |entry| {
|
for (page.window._performance._entries.items) |entry| {
|
||||||
if (self.interested(entry)) {
|
if (self.interested(entry)) {
|
||||||
@@ -123,7 +124,7 @@ pub fn observe(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (self.hasRecords()) {
|
if (self.hasRecords()) {
|
||||||
try self.dispatch(page);
|
try page.schedulePerformanceObserverDelivery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user