Web Development Bug Report

Android Chrome kills the tab in a 16-tile WebRTC grid: decode cost and simulcast layers

Our classroom app reloaded itself on mid-range Android phones whenever a class reached 16 students. Every tile decoded full 720p video. Choosing simulcast layers per tile and pausing offscreen video fixed it.

Amara Nwosu Amara Nwosu @amaranwosu · November 15, 2026 · 8 min read · 115 Views
578-webrtc-android-chrome-oom-grid-video-tracks

We build a live classroom app. Students join from whatever device they have, and in our market that means many mid-range Android phones with 4 GB of RAM. Teachers asked for a gallery view so they could see the whole class, and we shipped a 4x4 grid. Within a week the support inbox had a new pattern: "the class keeps restarting on my phone".

What students saw was the page going blank and reloading, losing the call. On a test device the Android log showed the Chrome renderer process for our tab being killed by the system while the foreground browser itself stayed alive:

ActivityManager: Process com.android.chrome:sandboxed_process0 (pid 21877) has died

It never happened with four or nine participants. It happened within one to three minutes once the grid filled past twelve tiles, and faster on phones with less memory.

Reproducing it

We set up a test room with 16 bot participants sending 1280x720 at 30 fps and joined from a Pixel-class mid-range device and two budget phones. With Chrome remote debugging attached over USB we could watch the tab's memory and CPU in DevTools while the grid filled up. On the 4 GB phones the renderer died every time. On an 8 GB flagship it survived, but the phone got hot and the frame rate across the grid dropped to single digits.

What we ruled out

  • A JavaScript memory leak. Heap snapshots were flat at about 60 MB. The growth was in native memory, outside the JavaScript heap.

  • Network bandwidth. The phones were on fast Wi-Fi and getStats() showed few lost packets. Bandwidth was high, not a bottleneck, which was part of the problem.

  • Our CSS grid. A static version of the grid with 16 <video> elements playing local files of the same resolution was smooth, which pointed at the live decode path rather than layout.

Root cause

The SFU forwarded every participant's highest quality layer to every receiver. Each phone was receiving and decoding sixteen 720p streams at once, even though each tile on a phone screen is about 180 pixels wide. Sixteen decoders plus their frame buffers pushed native memory past what the system allowed for a background-priority renderer, and Android's low memory handling killed it.

What is happening under the hood

Every remote video track in WebRTC has its own decoder instance and its own queue of decoded frames. Mobile chips have a limited number of hardware decoder sessions; once those are used, decoding falls back to software, which costs CPU and memory. A 720p frame in YUV 4:2:0 is about 1.4 MB, and the pipeline holds several frames per stream. Multiply by sixteen and add the GPU textures used to draw each tile, and a single tab can ask for hundreds of megabytes of native memory on a phone that also runs the system, the keyboard and other apps.

Android ranks processes by importance and reclaims memory from the least important first. Chrome runs each tab's content in a separate sandboxed renderer process, so the system can kill one tab without closing the browser. That is why students saw a reload instead of a full crash.

The fix is not a cleverer grid. It is sending each device only the pixels it can show. That is what simulcast is for: each sender encodes the same camera at several resolutions, and the SFU forwards the right layer to each receiver.

Environment

Component

Version / value

Devices

Android 14 and 15, 4 GB and 8 GB RAM

Browser

Chrome for Android 141

Media server

Open-source SFU with simulcast support

Sender config before fix

Single encoding, 1280x720, 30 fps, up to 2.5 Mbps

Grid

4x4 tiles, about 180x135 CSS pixels each on a phone

Minimal reproduction

The sender published a single encoding, and the receiver subscribed to every participant without saying how large the tile was:

// publish.js — before (excerpt)
const stream = await navigator.mediaDevices.getUserMedia({
  video: { width: 1280, height: 720, frameRate: 30 },
  audio: true,
});
stream.getTracks().forEach((t) => pc.addTrack(t, stream));

// subscribe.js — before (excerpt)
for (const p of room.participants) {
  sfu.subscribe(p.id, { video: true, audio: true }); // SFU picks the best layer it has
}

Who is affected

Any mesh or SFU app showing more than a handful of remote videos on phones, tablets or low-end laptops. Mesh calls are worse, because without an SFU there is no one to pick a layer for you, and each sender must also encode once per peer. Desktop users usually see high CPU and fan noise instead of a killed tab.

The fix

We changed three things: senders publish simulcast, receivers ask for a layer that matches each tile, and tiles that are not visible stop receiving video.

1. Publish three layers. addTransceiver with sendEncodings tells the browser to encode the same track at three resolutions. scaleResolutionDownBy is relative to the captured size.

// publish.js — after (excerpt)
const [video] = stream.getVideoTracks();
pc.addTransceiver(video, {
  direction: 'sendonly',
  streams: [stream],
  sendEncodings: [
    { rid: 'q', scaleResolutionDownBy: 4, maxBitrate: 150_000 },
    { rid: 'h', scaleResolutionDownBy: 2, maxBitrate: 500_000 },
    { rid: 'f', maxBitrate: 1_500_000 },
  ],
});

2. Subscribe per tile size. Our SFU accepts a preferred layer per subscription. We map the tile's rendered pixel size to a layer and update it when the layout changes. The exact API depends on your SFU; the idea is the same everywhere.

// subscribe.js — after (excerpt)
function layerFor(tileEl) {
  const px = tileEl.clientWidth * window.devicePixelRatio;
  if (px <= 360) return 'q';
  if (px <= 720) return 'h';
  return 'f';
}

const resize = new ResizeObserver((entries) => {
  for (const entry of entries) {
    const id = entry.target.dataset.participant;
    sfu.setPreferredLayer(id, layerFor(entry.target));
  }
});
document.querySelectorAll('.tile').forEach((t) => resize.observe(t));

3. Pause what nobody can see. On phones only part of the grid fits on screen. An IntersectionObserver tells the SFU to stop forwarding video for tiles that scroll out of view, and to resume when they come back. Audio stays subscribed.

const visibility = new IntersectionObserver((entries) => {
  for (const e of entries) {
    const id = e.target.dataset.participant;
    sfu.setVideoPaused(id, !e.isIntersecting);
  }
}, { threshold: 0.1 });

Stopping packets at the SFU matters more than hiding the element. A hidden <video> still has a track behind it, and as long as packets arrive the receive pipeline keeps working.

We also added a device budget. On devices where navigator.deviceMemory reports 4 or less, the grid caps at nine live tiles and shows the rest as avatars with an active-speaker ring.

Alternatives and trade-offs

  • SVC instead of simulcast. With codecs that support scalable video coding, a single stream carries spatial and temporal layers, and the SFU drops layers per receiver. It saves upload bandwidth for the sender but depends on codec and SFU support on every client you care about.

  • Lower the capture resolution for everyone. Simple, but it punishes the teacher's big screen and the active speaker tile.

  • Server-side composition (MCU). One mixed stream per receiver means one decoder per phone. It moves the cost to your servers and adds latency, and you lose per-tile control on the client.

How to test the fix

We repeated the 16-bot test on the same three phones and read the received resolution per track from getStats():

const report = await pc.getStats();
report.forEach((s) => {
  if (s.type === 'inbound-rtp' && s.kind === 'video') {
    console.log(s.trackIdentifier, s.frameWidth, s.frameHeight, s.framesPerSecond);
  }
});

Tiles in the grid now report 320x180, the pinned speaker reports 1280x720, and scrolled-out tiles stop increasing framesDecoded. Sessions of 45 minutes completed on all three phones without a renderer kill.

Confirming in production

We added two fields to our client quality beacon: the number of video tracks actively decoding and the sum of decoded pixels per second across them. On Android, the median decoded pixel rate in a 16-person class dropped by about 85 percent. The "class keeps restarting" tickets stopped within a week of rollout, and the share of Android sessions that ended without a user-initiated leave fell back to the level we saw before gallery view existed.

Regression guard

  • A synthetic test joins a 16-bot room from a real Android device in our device lab every night and fails if any tile larger than 360 device pixels is missing, or any small tile receives more than the quarter layer.

  • The SFU logs a warning when a subscriber requests the full layer for more than four tracks at once, which catches layout bugs that report wrong tile sizes.

Security implications

None beyond the usual for media apps. Simulcast does not change what is sent to whom, only at which resolution. Pausing offscreen video reduces the amount of personal video data a device holds in memory at a time. Make sure the pause signal is authorized per subscriber so one client cannot pause another participant's video for everyone.

Prevention checklist

  • Publish simulcast (or SVC) from every sender that can appear in a grid.

  • Request a layer from the tile's rendered size times devicePixelRatio, and update it on resize.

  • Stop forwarding video for tiles that are not visible; keep audio.

  • Cap live tiles on low-memory devices and fall back to avatars.

  • Test grids on a real 4 GB Android phone, not only on desktop emulation.

References

Add a label

#android #webrtc #chrome #simulcast #sfu
Written by
Amara Nwosu @amaranwosu

I build and maintain public and partner APIs, currently for a logistics platform with web, mobile and third-party clients all calling the same endpoints. Before that I worked on identity: login, sessions, OAuth integrations and the long tail of edge cases they create. The bugs I care about sit at the contract between client and server. A PUT that wiped fields the client never sent, a cache that served one user's page to another, a field removal that broke app versions still in the wild, a refresh flow that logged people out when two tabs raced. None of these show up in a happy-path demo. My posts walk through how each one surfaced, what the HTTP or auth spec actually says, the fix we shipped and the tests we added so the next change to the API does not repeat it.

Advertisement

Comments

0

No comments yet. Be the first to comment!

Sign In to post a comment.