mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
prefer low priority queue to execute performance observer
This commit is contained in:
@@ -1067,7 +1067,28 @@ pub fn notifyPerformanceObservers(self: *Page, entry: *Performance.Entry) !void
|
||||
}
|
||||
}
|
||||
|
||||
if (self._performance_delivery_scheduled == false) {
|
||||
self._performance_delivery_scheduled = true;
|
||||
try self.scheduler.add(
|
||||
self,
|
||||
struct {
|
||||
fn run(_page: *anyopaque) anyerror!?u32 {
|
||||
const page: *Page = @ptrCast(@alignCast(_page));
|
||||
page._performance_delivery_scheduled = true;
|
||||
// Dispatch performance observer events.
|
||||
for (page._performance_observers.items) |observer| {
|
||||
if (observer.hasRecords()) {
|
||||
try observer.dispatch(page);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}.run,
|
||||
0,
|
||||
.{ .low_priority = true },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn registerMutationObserver(self: *Page, observer: *MutationObserver) !void {
|
||||
|
||||
@@ -102,6 +102,8 @@ pub fn measure(
|
||||
page,
|
||||
);
|
||||
try self._entries.append(page.arena, m._proto);
|
||||
// Notify about the change.
|
||||
try page.notifyPerformanceObservers(m._proto);
|
||||
return m;
|
||||
},
|
||||
.start_mark => |start_mark| {
|
||||
@@ -125,12 +127,16 @@ pub fn measure(
|
||||
page,
|
||||
);
|
||||
try self._entries.append(page.arena, m._proto);
|
||||
// Notify about the change.
|
||||
try page.notifyPerformanceObservers(m._proto);
|
||||
return m;
|
||||
},
|
||||
};
|
||||
|
||||
const m = try Measure.init(name, null, 0.0, self.now(), null, page);
|
||||
try self._entries.append(page.arena, m._proto);
|
||||
// Notify about the change.
|
||||
try page.notifyPerformanceObservers(m._proto);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user