-
-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug and fix massive APK size, new in v27.170. #5086
Comments
At 506e712, I've been trying to pinpoint what AGP version the issue starts in. I've just tested 3.6.0 and 3.6.4 there, but I got build failures with different outputs on both of those. |
On |
Thanks for the debugging! Continued in a chat thread. |
Here's a (belated) write-up of what we learned in that debugging thread, with some small further points. I'll then file specific issues for subtasks. The figures below are from the latest release, v27.181. The APK has a total size of 131988583 bytes, 132.0MB. Of that, the sizes reported by The great bulk of the size of the APK comes from the native libraries,
That's 124MB.
|
@IzzySoft I'd be particularly interested in your perspective on this tradeoff, for after we've split the APKs up by ABI:
Which side of that tradeoff do you think would be best? |
I was reading your full text with quite some interest. I've never checked the install part: the APK is kept on-device, but I thought resources were always unpacked. Forgive my ignorance on details here: I'm no Android dev and I never dug into which parts of the APK were unpacked and which not; but there must be a reason why the APK is kept. We have such per-ABI builds at F-Droid as well. That split certainly has it advantages, as users only need to download the "stuff" needed for their device's architecture. Further, this brings your APKs closer to the 30M limit of my repo, where I then could pick e.g. the armeabi-v7a (which covers most devices, many arm64 ones included). The compression part is what I cannot estimate – it might need some on-device checking. Should it really bring down the APK size to around 15MB (or even less), I could keep multiple copies in my repo¹. For some low-end devices, size might be a concern – but then compare that to the uncompressed "fat build" shipped now, it'd still be an improvement, right? I'd say it would be a very good compromise worth testing. If compression seems not worth it, it can be turned off again anytime with a new release. Quick calc: instead of 130M mostly needing no unpacking, it then would be 10M (compressed) plus 30M (unpacked) = 40M on-device, so a clear win with a factor of 3 in savings and an "overhead" of 25% compared to uncompressed which otherwise would mean additional transfer and less copies kept on my server, but a potential factor 4 saving on the user's device. Sounds like a good deal to me, size-wise, if there are no other trade-offs. ¹ having more than one version in the repo helps when a user wants to install without having the index refreshed, while a newer version was already made available; it avoids the 404 caused otherwise, as the previous version would still be there |
OK, an update: with #5296, the new
Yeah, your instinct that there must be a reason the APK is kept around is right. I believe in general all the Android resources and also the "assets" files remain in the APK and are accessed directly from there, rather than making copies of them elsewhere on the device's storage. So with the change that happened in that AGP upgrade above, the system started doing the same for native libraries ( I just tried switching back to the old behavior (the switch is called
For each of those, I uninstalled the app completely, then installed it fresh with In short, by enabling that setting we could bring the APK size down by another 2x, from 35MB to about 17MB. The cost is that the size as actually installed on the user's device (including the APK) would go up, from about 45MB to 55MB. (Either way, both numbers will be much better than they are today before #5296.) |
OK, so we go with that 35M APK for now (so Zulip is at least close to the 30M limit of my repo), and experiment with the 17M version later? If you'd go for the latter, I could increase "versions kept" to 2 (to cover the install issue described above). Or you stick to the 35M to save those 10M (i.e. the size of 2 photos taken) on-device. I'm fine with both – just let me know what you decide for so I can adjust configuration on my end (including matching the correct APK to pull once you release – this might be the currently most important part, as if my updater fetches the wrong one we might be stuck with that if switching meant decreasing |
Yeah, we'll have that 35MB APK in the upcoming v27.182 release, and see how that goes. Then I think the next biggest opportunity for making things smaller will be:
I'm hopeful we'll be able to do that in the next month or two; I'll want to give it a try once we next upgrade our React Native version, to v0.65. There are some further space-saving opportunities in my comment at #5086 (comment) . It'll be interesting to pursue some of those once we're on Hermes. In the meantime, I'm going to close this issue as done -- the app is still larger than I'd like, but the APKs are a lot smaller than the massive size they became starting in v27.170, and in fact a little smaller than they've been for some time before that. (It looks like in v27.156 back in 2020 the APK was somewhat smaller, and then in v27.157 it grew.) |
Thanks @gnprice – any yes, looking forward to that! Should you come close to 15 MB (i.e. the half of the 30M limit), be welcome to send me a ping so I reconfigure for keeping 2 versions in my repo, as discussed. I won't look at the byte, so I'd do that also with 16M per APK 😉 |
It's been reported that our APK has gotten really big. The latest beta, v27.174, is 126 MB.
Looking at the GitHub releases, it went from 41.6 MB in v27.169 to 126 MB in v27.170. The most likely-looking thing in the v27.170 release notes is the RN v0.64 upgrade, #4426.
The text was updated successfully, but these errors were encountered: