Bug Description
During full-page screenshot capture, multiple large canvas objects are created and stored in the chunks array. These canvases are not explicitly cleaned up, leading to high memory usage and potential browser crashes on very large pages.
Steps To Reproduce
- Navigate to a very long webpage (10,000+ px height)
- Capture full page screenshot
- Monitor memory usage in browser DevTools
- Observe high memory consumption
- Multiple captures can crash the browser tab
Expected Behavior
- Canvas objects should be cleaned up after use
- Memory should be released between chunks
- Browser should remain stable even for very large pages
Actual Behavior
- Memory usage grows significantly during capture
- Canvas objects remain in memory
- Can cause browser tab crashes on large pages
Affected Files
src/js/content.js (Lines 476-615)
// Line 476-555: chunks array accumulates large objects
const chunks = [];
for (let chunkIndex = 0; chunkIndex < numChunks; chunkIndex++) {
const chunkCanvas = document.createElement('canvas');
// ... canvas grows to thousands of pixels
chunks.push(chunkCanvas); // No cleanup between pushes
}
Environment
- OS: All platforms
- Browser: Chrome, Firefox, Edge
- Version: 1.2.0
- Particularly affects: Large pages (>10,000px height)
Possible Solution
Explicitly cleanup resources and transfer data to blobs:
const chunks = [];
for (let chunkIndex = 0; chunkIndex < numChunks; chunkIndex++) {
const chunkCanvas = document.createElement('canvas');
// ... capture logic
// Convert to blob instead of keeping canvas
const blob = await new Promise(resolve =>
chunkCanvas.toBlob(resolve, 'image/png')
);
chunks.push(blob);
// Explicitly cleanup canvas
chunkCanvas.width = 0;
chunkCanvas.height = 0;
// Force garbage collection opportunity
if (chunkIndex % 3 === 0) {
await sleep(200);
}
}
Bug Description
During full-page screenshot capture, multiple large canvas objects are created and stored in the
chunksarray. These canvases are not explicitly cleaned up, leading to high memory usage and potential browser crashes on very large pages.Steps To Reproduce
Expected Behavior
Actual Behavior
Affected Files
src/js/content.js(Lines 476-615)Environment
Possible Solution
Explicitly cleanup resources and transfer data to blobs: