-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Generate ELF shared libraries and allow multi-abi libs in APKs and App bundles #33696
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
Conversation
|
Wondering what this change does to APK size. From the diff in the description it looks like it adds ~220KiB compressed? |
|
I tried building a default template app with The regular APK was 5.23MB and the The uncompressed Note that we had to disable the debug symbol stripping that Android usually does to |
|
Is the size increase likely due to the debug symbols? |
|
FYI: the config to avoid stripping debug symbols does not work in Flutter modules. It seems that the root cause is that the Gradle plugin is inserted as an implementation dependency: dependencies {
implementation project(':flutter')
}In which, any config set in the We may need to land a fix for dart-lang/sdk#37146 before this one goes in. |
|
The CI seems to be running into: https://github.com/dart-lang/sdk/blob/a6bbc58d09569ed84f437d6ff55c01166745b3d4/runtime/vm/dart_api_impl.cc#L6075. The target is still |
6af89f8 to
0dcfa51
Compare
|
Pending AIs:
|
|
mklim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending LGTM from other reviewers as well. :)
tvolkert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than a few nits, LGTM
There's a check before that. I have updated both error messages, so it's more clear. |
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tvolkert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| } | ||
|
|
||
| /** | ||
| * Returns the platform that is used to extract the `libflutter.so` and the .class files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really used to used to extract libflutter.so? It looks like it's only used to extract the .class files.
If I'm mis-reading it (and it is used to extract libflutter.so), is it not a problem that it's returning PLATFORM_ARM64 if that's merely one of the target platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It extracts libflutter.so as well, then it adds the libflutter.so for the rest of the ABIs.
Alternatively, we could extract the .class only before the afterEvaluate block (otherwise Gradle complains that we are referencing classes that aren't defined).
I filed an issue to track this in #33059 and #33064
The current engine artifacts for Android are:
android-arm/
android-arm-profile/
android-arm-release/
android-arm64/
android-arm64-profile/
android-arm64-release/
android-x64/
android-x86/
x64 and x86 are for debug only, and their corresponding libflutter.so is always added even for arm and arm64.
|
This change has doubled the measured size in the basic_material_app_android__compile benchmark. |
|
@jonahwilliams that's intended. Looks like the goal/baseline is defined in a db? |
Description
Include ELF shared library instead of AOT snapshots in APKs and make the flag
target-platformmulti-option forbuild apkandbuild appbundle.After this change, an APK built for release or profile will have the following structure:
2460 Defl:N 889 64% 1980-00-00 00:00 f40cf37a AndroidManifest.xml 765 Defl:N 595 22% 1980-00-00 00:00 dce0efa9 META-INF/CERT.RSA 1522 Defl:N 722 53% 1980-00-00 00:00 39881335 META-INF/CERT.SF 1479 Defl:N 695 53% 1980-00-00 00:00 ce61d107 META-INF/MANIFEST.MF 109 Defl:N 53 51% 1980-00-00 00:00 e83e6b87 assets/flutter_assets/AssetManifest.json 208 Defl:N 113 46% 1980-00-00 00:00 92d58e5f assets/flutter_assets/FontManifest.json 644419 Defl:N 58421 91% 1980-00-00 00:00 548a9a0b assets/flutter_assets/LICENSE 134640 Defl:N 63011 53% 1980-00-00 00:00 c7c94b78 assets/flutter_assets/fonts/MaterialIcons-Regular.ttf 97680 Defl:N 54923 44% 1980-00-00 00:00 273d62de assets/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf - 1821616 Defl:N 773152 58% 1980-00-00 00:00 10467cf1 assets/isolate_snapshot_data - 3060736 Defl:N 832709 73% 1980-00-00 00:00 0406652a assets/isolate_snapshot_instr - 23592 Defl:N 11409 52% 1980-00-00 00:00 0fa678e0 assets/vm_snapshot_data - 12704 Defl:N 2807 78% 1980-00-00 00:00 b5e3f0f0 assets/vm_snapshot_instr 258100 Defl:N 107181 59% 1980-00-00 00:00 5bc8eac3 classes.dex + 5632000 Defl:N 1850034 67% 1980-00-00 00:00 6415dcf7 lib/armeabi-v7a/libapp.so 6032316 Defl:N 3293989 45% 1980-00-00 00:00 c82f4361 lib/armeabi-v7a/libflutter.so 344 Defl:N 186 46% 1980-00-00 00:00 55202761 res/drawable/launch_background.xml 507 Stored 507 0% 1980-00-00 00:00 dab4e8f1 res/mipmap-hdpi-v4/ic_launcher.png 405 Stored 405 0% 1980-00-00 00:00 ad6e0a73 res/mipmap-mdpi-v4/ic_launcher.png 684 Stored 684 0% 1980-00-00 00:00 77d229a5 res/mipmap-xhdpi-v4/ic_launcher.png 994 Stored 994 0% 1980-00-00 00:00 547189ae res/mipmap-xxhdpi-v4/ic_launcher.png 1406 Stored 1406 0% 1980-00-00 00:00 63bc7c87 res/mipmap-xxxhdpi-v4/ic_launcher.pngFat APK
The tool displays a message:
Resulting APK:
2512 Defl:N 901 64% 00-00-1980 00:00 c7f247d8 AndroidManifest.xml 765 Defl:N 597 22% 00-00-1980 00:00 b105c0a9 META-INF/CERT.RSA 1678 Defl:N 777 54% 00-00-1980 00:00 45833d1e META-INF/CERT.SF 1635 Defl:N 747 54% 00-00-1980 00:00 a3af0ca9 META-INF/MANIFEST.MF 109 Defl:N 53 51% 00-00-1980 00:00 e83e6b87 assets/flutter_assets/AssetManifest.json 208 Defl:N 113 46% 00-00-1980 00:00 92d58e5f assets/flutter_assets/FontManifest.json 644419 Defl:N 58421 91% 00-00-1980 00:00 548a9a0b assets/flutter_assets/LICENSE 134640 Defl:N 63011 53% 00-00-1980 00:00 c7c94b78 assets/flutter_assets/fonts/MaterialIcons-Regular.ttf 97680 Defl:N 54923 44% 00-00-1980 00:00 273d62de assets/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf 257176 Defl:N 107353 58% 00-00-1980 00:00 8e495fa1 classes.dex 6311936 Defl:N 1801944 72% 00-00-1980 00:00 ed1058f5 lib/arm64-v8a/libapp.so 8473344 Defl:N 3657267 57% 00-00-1980 00:00 540aacd2 lib/arm64-v8a/libflutter.so 5632000 Defl:N 1850033 67% 00-00-1980 00:00 8abc54a5 lib/armeabi-v7a/libapp.so 6032316 Defl:N 3293989 45% 00-00-1980 00:00 c82f4361 lib/armeabi-v7a/libflutter.so 344 Defl:N 186 46% 00-00-1980 00:00 55202761 res/drawable/launch_background.xml 507 Stored 507 0% 00-00-1980 00:00 dab4e8f1 res/mipmap-hdpi-v4/ic_launcher.png 405 Stored 405 0% 00-00-1980 00:00 ad6e0a73 res/mipmap-mdpi-v4/ic_launcher.png 684 Stored 684 0% 00-00-1980 00:00 77d229a5 res/mipmap-xhdpi-v4/ic_launcher.png 994 Stored 994 0% 00-00-1980 00:00 547189ae res/mipmap-xxhdpi-v4/ic_launcher.png 1406 Stored 1406 0% 00-00-1980 00:00 63bc7c87 res/mipmap-xxxhdpi-v4/ic_launcher.png 1560 Stored 1560 0% 00-00-1980 00:00 71db73fd resources.arscABI split per APK
This will generate two APKs with the appropriate version for the the Play Store:
Related Issues
#18494
#31922
Tests
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.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?