← Dev log
EduQate·frontend

Two gyroscopes and an out-of-memory crash

Two decorative components each called useAnimatedSensor independently, leaking until the Fabric renderer threw java.lang.OutOfMemoryError failing a 16-byte allocation.

Only visible by using it

Invisible to a code read. Found by being the real user, on a real device, at a real width.

Got a live java.lang.OutOfMemoryError from the running app — Fabric renderer, failing to allocate 16 bytes on a nearly full heap. A tiny allocation failing usually means something has been leaking for a while rather than one big allocation blowing the budget.

GeometryField and InteractiveGeometry, two decorative components, each independently called useAnimatedSensor(SensorType.ROTATION, ...) — a real native subscription. They're used together constantly (auth, dashboard, organisations, programs, applications, documents, conversations, messages), so up to two live native listeners per screen at two polling intervals for as long as the screen stayed mounted. useAnimatedSensor also has a history across Reanimated versions of not tearing its listener down cleanly on fast refresh, and I'd been hot-reloading one of these screens repeatedly right before the crash.

Replaced with a shared context calling useAnimatedSensor once at the app root. A decorative component can hold a real native resource, and the cost never shows up until you're iterating on the exact tree it lives in. Two components independently reaching for the same platform capability is worth noticing even when each looks fine alone — same instinct as connection pooling.