Skip to content

Chrome Performance Paint Rectangles Debug Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Chrome Performance Paint Rectangles Debug Fix. We cover key concepts, practical examples, and best practices.

The Problem

Chrome DevTools Paint flashing shows green rectangles over areas being repainted. Excessive paint rectangles indicate inefficient rendering where the browser repaints more area than necessary, causing jank and high GPU usage.

Quick Fix

Step 1: Enable paint flashing in DevTools

// Wrong — guessing which elements repaint
// Right — enable paint flashing
// 1. Open Chrome DevTools (F12)
// 2. Settings (gear icon) > More Tools > Rendering
// 3. Check "Paint flashing"
// Green rectangles show areas being repainted

Step 2: Use will-change to promote layers

/* Wrong — every scroll repaints the entire element */
.animated-element {
    animation: slide 0.3s ease;
}

/* Right — promote to its own layer */
.animated-element {
    will-change: transform;
    animation: slide 0.3s ease;
}

/* Only repaint the element, not the whole page */

Step 3: Prefer transform and opacity

// Wrong — animating layout properties causes full repaint
element.style.left = '100px'; // Triggers layout + paint
element.style.width = '200px'; // Triggers layout + paint

// Right — animating compositor-only properties
element.style.transform = 'translateX(100px)'; // Compositor only
element.style.scale = '1.5'; // Compositor only
element.style.opacity = '0.5'; // Compositor only

Step 4: Reduce paint area with containment

/* Wrong — changes inside this element repaint the whole container */
.widget {
    transition: background-color 0.3s;
}

/* Right — contain repaints to the element */
.widget {
    contain: paint;
    transition: background-color 0.3s;
}

/* Or use content-visibility for off-screen elements */
.off-screen-section {
    content-visibility: auto;
    contain-intrinsic-size: 1px 500px; /* Placeholder size */
}

Step 5: Avoid repaint triggers

/* Wrong — box-shadow is expensive to paint */
.element {
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

/* Right — simpler shadow or use filter */
.element {
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

/* Wrong — border-radius with large areas */
.large-area {
    border-radius: 20px;
    background: linear-gradient(135deg, red, blue);
}

/* Right — simplify gradients and reduce border-radius on large elements */
.large-area {
    background: linear-gradient(135deg, red, blue);
}

Prevention

  • Keep paint rectangles small and focused — inspect with Paint flashing
  • Use will-change: transform for animated elements
  • Animate only transform and opacity for 60fps animations
  • Use contain: paint or content-visibility: auto for off-screen content
  • Avoid expensive paint properties like complex box-shadow on large areas

Common Mistakes with paint rects

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world PERF code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What do the different colored paint rectangles mean?

Green rectangles indicate paint areas. Red rectangles indicate layers being composited. Heavy green flashing means the browser repaints frequently — optimize by promoting elements to their own layers and using compositor-only properties.

How do I identify the exact element causing repaints?

Use the "Layers" tab in Chrome DevTools to see all composited layers. Use "Rendering > Paint Flashing" to spot repaint areas. Use the "Performance" tab and capture a recording — look for purple "Paint" events in the Main thread.

Does will-change have performance downsides?

Yes. Overusing will-change creates too many layers, consuming GPU memory. Apply it only to elements you actively animate and remove it when the animation ends. Use will-change: auto to reset.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro