Deallocate JNI array after TextInput text measurement

Summary:
Every time we measure a TextInput we allocate a JNI local array and weren't cleaning it up, leading to JNI table exhaustion.

Changelog: [Internal]

Differential Revision: D23670780

fbshipit-source-id: 2ecf9770c8593eeadd70a248be58037fefdca61e
This commit is contained in:
Joshua Gross
2020-09-12 21:53:22 -07:00
committed by Facebook GitHub Bot
parent 44229d9149
commit 0b3f46b564
@@ -88,6 +88,10 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById(
maximumSize.height,
attachmentPositions));
// Clean up allocated ref - it still takes up space in the JNI ref table even
// though it's 0 length
env->DeleteLocalRef(attachmentPositions);
// TODO: currently we do not support attachments for cached IDs - should we?
auto attachments = TextMeasurement::Attachments{};
@@ -172,8 +176,10 @@ TextMeasurement TextLayoutManager::doMeasure(
}
}
}
// DELETE REF
// Clean up allocated ref
env->DeleteLocalRef(attachmentPositions);
return TextMeasurement{size, attachments};
}