fix(crashlytics,android): avoid heap-loading libapp.so for build ID - #18483
fix(crashlytics,android): avoid heap-loading libapp.so for build ID#18483SelaseKay wants to merge 5 commits into
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
This fixes the OOM, but it more than doubles the time this plugin holds the main thread during startup — I built the branch and measured it on a device before merge. Three release APKs of the same app, identical build config,
This is synchronous main-thread work inside It also scales with the app. Our To be straight about the limits of my data: end-to-end One more thing about the temp file, on the failure path: if the process is killed between A bounded prefix fixes the OOM and speeds startup upIt's the only one of the three that improves on the status quo: the slice drops from 16.1 ms to 0.63 ms and registration goes from 21.8 to 10.0 ms. The idea is to make every allocation sized by a constant, never by a value read from the file, which removes the OOM at its source instead of relocating it to the filesystem: private static final int INITIAL_PREFIX_BYTES = 4 * 1024;
private static final int MAX_PREFIX_BYTES = 256 * 1024;
private static final int MAX_DESC_BYTES = 1024;Read that prefix from the entry, parse it in memory with bounds checks on every offset, and if a note ever sat beyond it, retry once with a capped larger prefix. Note that I ran the parser offline against all 12 shared objects in my release APK ( It doesn't reach zero — Full source below; this is exactly what produced the 0.63 ms row. Happy to open it as a PR with unit tests for the parser — the package has no
|
Description
Fixes an Android
firebase_crashlyticsstartup OOM when libapp.so is stored inside the APK/split APK.Previously, ElfBuildIdReader loaded the entire
libapp.soZIP entry into a byte array to read the ELF build ID. Large Flutter native libraries could exceed the app heap limit and crash during plugin registration. This now streams the ZIP entry to a temp file with a fixed-size buffer and reuses the existing file-based ELF parser. Build ID extraction also fails gracefully instead of crashing startup.Related Issues
Fixes #18480
Replace this paragraph with a list of issues related to this PR from the issue database. Indicate, which of these issues are resolved or fixed by this PR. Note that you'll have to prefix the issue numbers with flutter/flutter#.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]).This will ensure a smooth and quick review process. Updating the
pubspec.yamland changelogs is not required.///).melos run analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?