feat(ui): add flicker detection and metrics (#10821)

This commit is contained in:
Shreya Keshive
2025-10-10 13:18:38 -07:00
committed by GitHub
parent ab3804d823
commit ae48e964f0
13 changed files with 297 additions and 39 deletions

View File

@@ -5,6 +5,7 @@
*/
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { appEvents, AppEvent } from '../../utils/events.js';
import {
profiler,
ACTION_TIMESTAMP_CAPACITY,
@@ -157,6 +158,18 @@ describe('DebugProfiler', () => {
expect(profiler.totalIdleFrames).toBe(3);
});
it('should report flicker frames', () => {
const reportActionSpy = vi.spyOn(profiler, 'reportAction');
const cleanup = profiler.registerFlickerHandler(true);
appEvents.emit(AppEvent.Flicker);
expect(profiler.totalFlickerFrames).toBe(1);
expect(reportActionSpy).toHaveBeenCalled();
cleanup();
});
it('should not report idle frames when actions are interleaved', async () => {
const startTime = Date.now();
vi.setSystemTime(startTime);