feat: disable canvas events performance monitoring

This commit is contained in:
amhsirak
2025-01-06 19:44:04 +05:30
parent 5ddfc91f8e
commit 0497653ca9

View File

@@ -2,7 +2,6 @@ import React, { useCallback, useEffect, useRef, useMemo, Suspense } from 'react'
import { useSocketStore } from '../../context/socket'; import { useSocketStore } from '../../context/socket';
import { useGlobalInfoStore } from "../../context/globalInfo"; import { useGlobalInfoStore } from "../../context/globalInfo";
import { useActionContext } from '../../context/browserActions'; import { useActionContext } from '../../context/browserActions';
import { FrontendPerformanceMonitor } from '../../../perf/performance';
const DatePicker = React.lazy(() => import('./DatePicker')); const DatePicker = React.lazy(() => import('./DatePicker'));
const Dropdown = React.lazy(() => import('./Dropdown')); const Dropdown = React.lazy(() => import('./Dropdown'));
const TimePicker = React.lazy(() => import('./TimePicker')); const TimePicker = React.lazy(() => import('./TimePicker'));
@@ -162,7 +161,7 @@ const Canvas = React.memo(({ width, height, onCreateRef }: CanvasProps) => {
const scheduler = useRef(new RAFScheduler()); const scheduler = useRef(new RAFScheduler());
const debouncer = useRef(new EventDebouncer(scheduler.current)); const debouncer = useRef(new EventDebouncer(scheduler.current));
const measurementCache = useRef(new MeasurementCache(50)); const measurementCache = useRef(new MeasurementCache(50));
const performanceMonitor = useRef(new FrontendPerformanceMonitor()); //const performanceMonitor = useRef(new FrontendPerformanceMonitor());
const refs = useRef({ const refs = useRef({
getText, getText,
@@ -204,7 +203,7 @@ const Canvas = React.memo(({ width, height, onCreateRef }: CanvasProps) => {
const handleMouseEvent = useCallback((event: MouseEvent) => { const handleMouseEvent = useCallback((event: MouseEvent) => {
if (!socket || !canvasRef.current) return; if (!socket || !canvasRef.current) return;
performanceMonitor.current.measureEventLatency(event); //performanceMonitor.current.measureEventLatency(event);
const coordinates = getEventCoordinates(event); const coordinates = getEventCoordinates(event);
switch (event.type) { switch (event.type) {
@@ -297,13 +296,13 @@ const Canvas = React.memo(({ width, height, onCreateRef }: CanvasProps) => {
}, [handleMouseEvent, handleKeyboardEvent, onCreateRef]); }, [handleMouseEvent, handleKeyboardEvent, onCreateRef]);
// Performance monitoring // Performance monitoring
useEffect(() => { // useEffect(() => {
const intervalId = setInterval(() => { // const intervalId = setInterval(() => {
console.log('Performance Report:', performanceMonitor.current.getPerformanceReport()); // console.log('Performance Report:', performanceMonitor.current.getPerformanceReport());
}, 20000); // }, 20000);
return () => clearInterval(intervalId); // return () => clearInterval(intervalId);
}, []); // }, []);
useEffect(() => { useEffect(() => {
if (!socket) return; if (!socket) return;