diff --git a/debug-render-analysis.js b/debug-render-analysis.js deleted file mode 100644 index 51c90eec2f6..00000000000 --- a/debug-render-analysis.js +++ /dev/null @@ -1,228 +0,0 @@ -/** - * Render Analysis Debug Script - * - * This script can be pasted into the browser console to help analyze - * component render patterns and detect potential infinite renders. - * - * Usage: - * 1. Open browser DevTools (F12) - * 2. Go to Console tab - * 3. Paste this entire script and press Enter - * 4. Use the application normally - * 5. Call analyzeRenders() to see the analysis - */ - -// Global variables to track renders -window.renderTracker = { - logs: [], - startTime: Date.now(), - componentCounts: {}, - lastRenderTimes: {}, - suspiciousPatterns: [], -}; - -// Override console.log to capture our render logs -const originalConsoleLog = console.log; -console.log = function (...args) { - // Call original console.log first - originalConsoleLog.apply(console, args); - - // Check if this is one of our render logs - const message = args[0]; - if ( - typeof message === "string" && - (message.includes("๐ GUIComponent RENDER:") || - message.includes("๐งฑ Blocks") || - message.includes("๐ญ StageWrapperComponent RENDER:") || - message.includes("๐ฏ TargetPane")) - ) { - const timestamp = Date.now(); - const logEntry = { - timestamp, - message, - data: args[1] || {}, - component: extractComponentName(message), - }; - - window.renderTracker.logs.push(logEntry); - - // Track component render counts - const component = logEntry.component; - window.renderTracker.componentCounts[component] = - (window.renderTracker.componentCounts[component] || 0) + 1; - - // Check for rapid re-renders (potential infinite renders) - if (window.renderTracker.lastRenderTimes[component]) { - const timeDiff = - timestamp - window.renderTracker.lastRenderTimes[component]; - if (timeDiff < 100) { - // Less than 100ms between renders - window.renderTracker.suspiciousPatterns.push({ - component, - timeDiff, - timestamp, - message: `Rapid re-render detected: ${component} rendered ${timeDiff}ms after previous render`, - }); - } - } - window.renderTracker.lastRenderTimes[component] = timestamp; - } -}; - -function extractComponentName(message) { - if (message.includes("๐ GUIComponent")) return "GUIComponent"; - if (message.includes("๐งฑ Blocks")) return "Blocks"; - if (message.includes("๐ญ StageWrapperComponent")) - return "StageWrapperComponent"; - if (message.includes("๐ฏ TargetPane")) return "TargetPane"; - return "Unknown"; -} - -// Analysis functions -window.analyzeRenders = function () { - const tracker = window.renderTracker; - const totalTime = Date.now() - tracker.startTime; - - console.group("๐ RENDER ANALYSIS REPORT"); - console.log(`๐ Analysis Period: ${(totalTime / 1000).toFixed(2)} seconds`); - console.log(`๐ Total Render Logs: ${tracker.logs.length}`); - - console.group("๐ Component Render Counts"); - Object.entries(tracker.componentCounts) - .sort(([, a], [, b]) => b - a) - .forEach(([component, count]) => { - const rate = (count / (totalTime / 1000)).toFixed(2); - console.log(`${component}: ${count} renders (${rate} renders/sec)`); - }); - console.groupEnd(); - - if (tracker.suspiciousPatterns.length > 0) { - console.group("โ ๏ธ SUSPICIOUS PATTERNS (Potential Infinite Renders)"); - tracker.suspiciousPatterns.forEach((pattern) => { - console.warn(pattern.message); - }); - console.groupEnd(); - } else { - console.log("โ No suspicious rapid re-render patterns detected"); - } - - console.group("๐ Recent Renders (Last 10)"); - tracker.logs.slice(-10).forEach((log) => { - const timeFromStart = ( - (log.timestamp - tracker.startTime) / - 1000 - ).toFixed(2); - console.log(`[${timeFromStart}s] ${log.message}`, log.data); - }); - console.groupEnd(); - - console.groupEnd(); - - return { - totalRenders: tracker.logs.length, - componentCounts: tracker.componentCounts, - suspiciousPatterns: tracker.suspiciousPatterns, - analysisTime: totalTime, - }; -}; - -window.clearRenderTracking = function () { - window.renderTracker = { - logs: [], - startTime: Date.now(), - componentCounts: {}, - lastRenderTimes: {}, - suspiciousPatterns: [], - }; - console.log("๐งน Render tracking data cleared"); -}; - -window.getRendersByComponent = function (componentName) { - return window.renderTracker.logs.filter( - (log) => log.component === componentName - ); -}; - -window.getRecentRenders = function (seconds = 10) { - const cutoff = Date.now() - seconds * 1000; - return window.renderTracker.logs.filter((log) => log.timestamp > cutoff); -}; - -// Utility function to detect useEffect dependency issues -window.detectDependencyIssues = function () { - const recentLogs = window.getRecentRenders(30); - const guiRenders = recentLogs.filter( - (log) => log.component === "GUIComponent" - ); - - console.group("๐ DEPENDENCY ANALYSIS"); - - if (guiRenders.length > 5) { - console.warn( - `โ ๏ธ GUIComponent rendered ${guiRenders.length} times in the last 30 seconds` - ); - console.log("This might indicate useEffect dependency issues"); - - // Check for useEffect logs - const useEffectLogs = recentLogs.filter((log) => - log.message.includes("useEffect") - ); - - if (useEffectLogs.length > 0) { - console.group("๐ Recent useEffect executions:"); - useEffectLogs.forEach((log) => { - console.log(log.message, log.data); - }); - console.groupEnd(); - } - } else { - console.log("โ GUIComponent render frequency looks normal"); - } - - console.groupEnd(); -}; - -// Auto-analysis every 30 seconds -let autoAnalysisInterval; -window.startAutoAnalysis = function () { - if (autoAnalysisInterval) { - clearInterval(autoAnalysisInterval); - } - - autoAnalysisInterval = setInterval(() => { - const suspiciousCount = window.renderTracker.suspiciousPatterns.length; - if (suspiciousCount > 0) { - console.warn( - `๐จ AUTO-ANALYSIS: ${suspiciousCount} suspicious render patterns detected!` - ); - window.analyzeRenders(); - } - }, 30000); - - console.log("๐ค Auto-analysis started (runs every 30 seconds)"); -}; - -window.stopAutoAnalysis = function () { - if (autoAnalysisInterval) { - clearInterval(autoAnalysisInterval); - autoAnalysisInterval = null; - console.log("๐ Auto-analysis stopped"); - } -}; - -// Initialize -console.log("๐ Render Analysis Debug Script Loaded!"); -console.log("Available functions:"); -console.log(" - analyzeRenders() - Show detailed analysis"); -console.log(" - clearRenderTracking() - Clear tracking data"); -console.log( - " - getRendersByComponent(name) - Get renders for specific component" -); -console.log(" - getRecentRenders(seconds) - Get recent renders"); -console.log(" - detectDependencyIssues() - Check for useEffect issues"); -console.log(" - startAutoAnalysis() - Start automatic monitoring"); -console.log(" - stopAutoAnalysis() - Stop automatic monitoring"); -console.log(""); -console.log( - "๐ก Tip: Use the application normally, then call analyzeRenders() to see the results" -); diff --git a/package.json b/package.json index fd02f1cc2f7..e35fb0723a1 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,7 @@ "default": "./src/index.js" }, "scripts": { - "build": "npm run clean && NODE_ENV=production webpack && cp -r ./build/ ../public/scratch", - "build:dev": "npm run clean && webpack && cp -r ./build/ ../public/scratch", + "build": "npm run clean && webpack && cp -r ./build/ ../public/scratch", "clean": "rimraf ./build ./dist", "deploy": "touch build/.nojekyll && gh-pages -t -d build -m \"[skip ci] Build for $(git log --pretty=format:%H -n1)\"", "prepublish": "node scripts/prepublish.mjs", diff --git a/src/components/controls/controls.jsx b/src/components/controls/controls.jsx index b1b728ae633..59be3a0f9c5 100644 --- a/src/components/controls/controls.jsx +++ b/src/components/controls/controls.jsx @@ -29,7 +29,6 @@ const Controls = function (props) { const { active, className, - costumeURLFax, intl, onGreenFlagClick, onStopAllClick, @@ -124,4 +123,4 @@ const mapStateToProps = (state) => ({ flagClicked: state.scratchGui.vmStatus.flagClicked, }) -export default injectIntl(connect(mapStateToProps, () => ({}))(Controls)) +export default injectIntl(connect(mapStateToProps, null)(Controls)) diff --git a/src/components/customi-cons/reload.jsx b/src/components/customi-cons/reload.jsx index d709ba27e78..89e3f16be31 100644 --- a/src/components/customi-cons/reload.jsx +++ b/src/components/customi-cons/reload.jsx @@ -4,8 +4,8 @@ import styles from './reload.css' function Reload() { return (