# Autopsy #09: 60 FPS on MacBook Pro, 11 FPS on Mid-Range Android

- **Canonical URL:** https://frontend.rocks/autopsies/mobile-scroll-jank-vram-explosion/
- **Case:** #09
- **Failure Mode:** Memory Exhaustion
- **Production Symptom:** A card grid scrolls at 60 FPS on MacBook Pro but stutters at 11 FPS and OOM-kills the browser tab on mid-range Android.
- **Last Verified:** 2026-11-16

## Causal Chain
1. [Paint & Rasterization](https://frontend.rocks/concepts/paint-rasterization.md): Shadow and border-radius invalidations force CPU software rasterization across hundreds of card tiles per scroll frame.
2. [GPU Compositor Layers and will-change](https://frontend.rocks/concepts/gpu-compositor-layers.md): Blanket will-change: transform promotes 80 cards into permanent GPU textures, exhausting mobile tile memory.
3. [CSS Containment](https://frontend.rocks/concepts/css-containment.md): Without layout and paint containment, expanding one card badge invalidates the entire document tree.
4. [content-visibility & Skipping Offscreen Work](https://frontend.rocks/concepts/content-visibility.md): Offscreen cards remain in the active style, layout, and paint pipeline despite sitting 4,000px below the fold.
5. [Scroll-Driven Animations](https://frontend.rocks/concepts/scroll-driven-animations.md): A main-thread scroll listener mutates inline styles per frame instead of running compositor-bound scroll timelines.

## Primary Sources
- https://developer.chrome.com/docs/css-ui/content-visibility
- https://drafts.csswg.org/css-contain-2/
- https://drafts.csswg.org/scroll-animations-1/

---
## Incident Report

A routine storefront redesign added multi-stop `box-shadow` elevation and a parallax hero banner to an 80-card catalog grid. It held 60 FPS on M3 MacBook Pros during design review.

- **T+00:00**: Deployed the catalog update to 100% of mobile web traffic.
- **T+04:00**: Android RUM telemetry flagged scroll frame rates collapsing to 11 FPS on Moto G and Pixel 6a devices, with main-thread frame times exceeding 88 ms.
- **T+11:00**: Mobile GPU process memory climbed past 380 MB on initial page load.
- **T+18:00**: Chrome crash reporting recorded a 14% tab OOM-kill rate (`RESULT_CODE_HUNG`) within 30 seconds of catalog scroll.

## The Red Herring

In `#perf-triage`, the team assumed Blink was software-rasterizing cards because they lacked GPU acceleration. An engineer shipped `will-change: transform; transform: translateZ(0);` on `.product-card` to force hardware compositing.

It looked smooth on a 16 GB desktop GPU. On mid-range Android, promoting all 80 cards upfront allocated 80 persistent backing textures in VRAM, dropping scroll FPS further and doubling tab OOM kills.

## Causal Chain

Desktop unified memory hides unbounded layer promotion and full-tree invalidations. On constrained mobile GPUs, software rasterization pressure, blanket layer promotion, missing CSS containment, eager offscreen rendering, and main-thread scroll listeners compound into VRAM exhaustion.

## Failure Simulator

Adjust the card count and toggle static `will-change: transform` in the simulator below to observe how GPU layer allocation scales into mobile VRAM exhaustion.

## Layer Dissection

### 01 → 02: Rasterization Pressure Triggers Blanket Layer Promotion

Multi-stop `box-shadow` and `backdrop-filter` rules increase [Paint & Rasterization](/concepts/paint-rasterization) cost on every scroll frame. Applying `will-change: transform` to every card forces [GPU Compositor Layers and will-change](/concepts/gpu-compositor-layers) promotion for all 80 items, locking 160+ MB of mobile VRAM at 3x DPR.

### 02 → 03: Missing Containment Amplifies Invalidations

Because each card lacked [CSS Containment](/concepts/css-containment) (`contain: layout style paint`), a dynamic stock badge update or image decode inside one card invalidated sibling and ancestor layout boxes across the entire feed.

### 03 → 04: Offscreen Cards Burn Memory and Layout Budget

With 80 cards in the DOM, 72 sit outside the viewport at any moment. Without [content-visibility & Skipping Offscreen Work](/concepts/content-visibility) (`content-visibility: auto` plus `contain-intrinsic-size`), Blink styles, lays out, and allocates raster tiles for cards 4,000 pixels below the fold.

### 04 → 05: Main-Thread Scroll Listeners Block the Compositor

A `scroll` event listener read `window.scrollY` and wrote `element.style.transform` on every frame, forcing synchronous style recalculation. Replacing that handler with CSS [Scroll-Driven Animations](/concepts/scroll-driven-animations) (`animation-timeline: scroll()`) moves the parallax calculation off the main thread onto the compositor.

## Architectural Fix & Invariants

```css
/* product-grid.css */
.product-card {
  contain: layout style paint;
  content-visibility: auto;
  contain-intrinsic-size: auto 340px;
}

.product-card:hover {
  will-change: transform;
}

.hero-parallax {
  animation: parallax-shift linear both;
  animation-timeline: scroll(root block);
}
```

**Architectural Invariants**

- **Zero static `will-change` on list items**: Layer promotion is restricted to active hover or transition windows; lists never hold more than 12 persistent GPU textures.
- **Skip offscreen work by default**: Feeds exceeding 20 cards apply `content-visibility: auto` with an explicit `contain-intrinsic-size` to bound initial layout and raster memory.
- **Compositor-only scroll effects**: Scroll-linked transforms use `animation-timeline: scroll()` or `view()`, never `window.addEventListener('scroll')` mutating inline styles.

**Golden Rule:** GPU layers are finite VRAM allocations, not free speed flags; isolate layout with containment, skip offscreen cards, and promote layers only while they animate.
