Menu

My React simulator ran at 4 FPS on an iPhone. The cause was a 50000px SVG with backdrop-blur on top.

#reactjs#redditreactjs#latency#node#react
Reading 0:00
15s threshold

I'm building a browser tool that simulates system diagrams. Nodes have a capacity and a latency, and small packets travel along the edges. There's no canvas library, only DOM nodes, native SVG and a requestAnimationFrame loop.

On my laptop it was smooth. On my phone it ran at about 4 FPS.

I'd made the SVG layer 50000x50000px so wires wouldn't get clipped when you pan far away, and the node cards had Tailwind's backdrop-blur. Mobile browsers seem to allocate a huge texture for an element like that. A viewport-sized layer with overflow-visible, plus the blur only from md: up, fixed most of it.

React was also re-rendering every node card each frame just to update a queue counter. The loop now reads from refs and a lookup map instead. Counters update about four times a second, and on touch devices I commit state at roughly 33 FPS while keeping packet speed the same.

Latency is the node's base latency times a multiplier that grows with the square of utilization.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.