Our Android APK was carrying two native libraries that no JavaScript file used anymore.
-
librnskia.so: 41 MB across 4 ABIs. Skia stayed inpackage.jsonafter we replaced our charts with plainreact-native-svgrings and Views. -
WebRTC (
libjingle_peerconnection_so.so): 41 MB across ABIs. It was left over from a voice path we had already retired. Worse, it was beingdlopen'd 574 ms into every cold start, before the first frame, for code nothing imported.
The lesson
Autolinking compiles a library's native code into the APK whether or not any JS imports it. A package you "parked" in package.json for later is not free. You pay for it in download size and, sometimes, in startup time.
How we found them
-
Break the APK down by ABI, library and asset. We have a small script (
yarn perf apk) that unzips the build and sorts every.soby size. Two 41 MB entries for features we no longer shipped stood out immediately. -
Watch what loads at startup. A second script (
yarn perf soload) reads logcat during a cold start and lists every.sothat loads, with a timestamp. That's how WebRTC showed up at 574 ms. -
Remove it and make sure it stays removed. We deleted the packages and added an ESLint
no-restricted-importsentry for each one, with the reason in the message, so nobody adds them back without reading why.
Bonus: BlurView on Android
On iOS, BlurView is a hardware-accelerated UIVisualEffectView. On Android it re-samples the whole view tree into a bitmap and blurs it every frame for as long as it is mounted.
Our floating action menu used a full-screen blur and measured p50 51 ms and p95 101 ms per frame, with 8.3% of frames over 100 ms. It was the worst interaction in the app. Replacing the blur with a flat scrim on Android (keeping the blur on iOS) fixed it.
Takeaways
- Audit your APK by library, not just total size.
- Check which native libraries load before your first frame.
- Remove unused native packages and lint against them coming back.
- Gate full-screen blur to iOS.
I'm building Finovaa, an AI budgeting coach for iOS and Android, currently in store review.
Top comments (1)
The
soloadlogcat trick is a nice one, I hadn't thought of timing the dlopen at cold start. On the native side we build our own FFmpeg and libVLC, LGPL-only and with no video encoders, which keeps both the size and the licence in check. A per-ABI size breakdown like youryarn perf apkis what keeps that honest over time.