Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Embed ICU data inside libflutter.so on Android #7588

Merged
merged 1 commit into from
Jan 30, 2019

Conversation

jason-simmons
Copy link
Member

@jason-simmons jason-simmons commented Jan 25, 2019

The advantage of this is simpler packaging of the APK, less risk at runtime, and faster startup time.

Previously icudtl.dat was packaged as an asset in the flutter_shared directory within the APK zip file. The Gradle script had to ensure that icudtl.dat is placed there exactly once (even if multiple Flutter apps are packaged within the APK).

At runtime, the Android embedder code had to extract icudtl.dat out of the APK and write it to local disk before the engine can start. We've seen situations where something goes wrong with that process and the app crashes because the on disk copy is malformed.

With this change, the ICU data is available through a symbol lookup in the Flutter library and does not need to be copied to local storage.

The APK size should be unchanged if there is only one version of libflutter.so in the APK (the data is just being moved out of the standalone asset and into libflutter.so). However, if an APK is built with multiple versions of libflutter.so for different architectures, then the ICU data will be duplicated in each libflutter.so

@@ -96,6 +96,7 @@ struct Settings {
bool verbose_logging = false;
std::string log_tag = "flutter";
std::string icu_data_path;
std::string icu_symbol;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a MappingCallback instead. That way, the embedders can setup the mapping from whatever source they choose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

subprocess.check_call([
args.objcopy,
'-I', 'binary',
'-O', 'elf32-littlearm',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't architecture agnostic. Thinking of release modes for Android aarch64, x64, etc..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@chinmaygarde
Copy link
Member

Just a heads up, I tried compiling the same locally on Mac but ran into the same issue as the buildbots.

@jason-simmons
Copy link
Member Author

The build errors are happening because this needs to be combined with a roll to flutter/buildroot#211

Prior to this the Android embedder code would extract the icudtl.dat asset out
of the APK and write it to local disk during the first startup of the app.

This change will make that work unnecessary and eliminate the risk of ICU
failures due to errors in the extraction process.
@jason-simmons jason-simmons merged commit 050dcaa into flutter:master Jan 30, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 3, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 3, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 4, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants