A small game team once stared at the frame-rate panel for half an hour: FPS looked fine, yet users said it stuttered; a closer look showed CPU at zero percent while frames dropped. That sounds like mysticism, but it is a tax specific to mini-programs — the bridge tax. In the wave of mini-games, 60fps is the product itself: whether a level feels smooth decides whether a user stays. And the bridge swaps the native "follows your finger" for "like a webpage someone emailed you."
The bridge is the bottleneck, not the algorithm
Mini-program performance does not depend on how elegant the sort algorithm is; it depends on two costs the runtime adds on top of ordinary web performance. The first, and nastiest, is the bridge: every time JS calls native, or native calls back, the arguments are serialized on both sides. One call is invisible, but in a frequently run path — a scroll callback, an animation frame — it fires dozens of times, and the main thread jams on those serializations. So CPU is not computing (hence zero), but frames do not draw, because the main thread is stuck waiting on the bridge.
Before and after: fifty bridges become one
The common anti-pattern asks the native layer individually for each list item in one render:
// wrong: fifty bridge crossings in one render
for (const item of items) {
const meta = await native.getMeta(item.id);
paint(item, meta);
}
Batch it, and the bridge drops from fifty crossings to one:
// right: one bridge call for all
const metas = await native.getMetaBatch(items.map(i => i.id));
items.forEach((item, i) => paint(item, metas[i]));
| Approach | Bridge calls | Serialized bytes | Measured frame time |
|---|---|---|---|
| Per-item | 50 | ~12 KB | Frame drops |
| Batch | 1 | ~12 KB | Stable |
The byte total is identical; the difference is entirely in "how many times you cross the boundary." The bridge is billed per crossing, not per byte.
What the frame budget is worth
The 60fps budget is 16.7 milliseconds per frame, and what is left for the script and the bridge is usually under 10. One bridge call on a low-end device measures 0.3 to 1 millisecond — trivial alone, but a loop that crosses 30 times per frame spends 9 to 30 milliseconds on the bridge and blows the budget. That is why "FPS fine, CPU zero, frames drop": the main thread is not computing, it is waiting to cross. Pushing per-frame crossings into single digits often helps more than optimizing any algorithm. Count the crossings, and a team learns who ate the 16.7 milliseconds.
Beyond batching: three more moves
Batching is only the first move against the bridge serialization tax. The second is throttling: storage reads and writes are easily retriggered in hot paths, so debounce them to once per frame. The third is frame coalescing: merge multiple state updates into one bridge crossing instead of crossing on every setState. The fourth is reducing copies — pass large objects via structured clone or transferable rather than serializing a copy on each side. On a WebView 94 device, stacking these moves pulls a persistently stuttering list back to a stable 60, and their prerequisite is that bridge counter: know the count to know where to press.
Measure on the device that hurts
The bridge counter is useless if it only ever runs on a flagship. The whole point is to surface the crossing count on the 3 GB RAM, WebView 94 device where frames actually drop, not on the developer's laptop where fifty crossings feel free. One team shipped the counter and discovered their animation loop crossed the bridge 30 times per frame on low-end hardware — invisible on desktop — and after compressing to 3 crossings the same device went from persistent jank to a stable 60. Without measuring on the device that hurts, the bridge tax stays filed under "low-end devices are just slow."
The bottom line
Mini-program stutter is eight times out of ten not a slow algorithm but a bridge called too often. Count the crossings, batch the hot paths, then suspect the code — that is the optimization that actually works on low-end devices.