Post

I was exploring a hard to debug memory leak in react native for at least 6 hours today. Turns out that when you don't add accessibilityLabel to RectButton or Pressable, it will fucking traverse all children to find a Text node or View with accessibilityLabel. This is insane. 1/4

Is this an actual memory leak? From the code samples, it looks like it should pile up some memory but then let that go. I agree this isn't a good default, and perhaps a dev-only warning saying "need an accessibility label on <view name>" would be best.

From 300MB to 7GB plus a full hang is even worse. Yeah, it’s not a leak, but an infinite traversal bug. In some very rare and not reliably reproducible cases, nested touchables can trigger this bug and completely freeze the app in our case. Adding a fallback `accessibilityLabel` did the trick.

Generally speaking, I don’t like these automated and expensive lookups. I’d rather have a dev-only warning that forces users to handle accessibility manually. And lookups should bail out fast and have some railguards.

0 reposts4 likes