-
Notifications
You must be signed in to change notification settings - Fork 6k
Embed ICU data inside libflutter.so on Android #7588
Conversation
common/settings.h
Outdated
@@ -96,6 +96,7 @@ struct Settings { | |||
bool verbose_logging = false; | |||
std::string log_tag = "flutter"; | |||
std::string icu_data_path; | |||
std::string icu_symbol; |
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.
Can you make this a MappingCallback
instead. That way, the embedders can setup the mapping from whatever source they choose.
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.
done
sky/tools/objcopy.py
Outdated
subprocess.check_call([ | ||
args.objcopy, | ||
'-I', 'binary', | ||
'-O', 'elf32-littlearm', |
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.
This isn't architecture agnostic. Thinking of release modes for Android aarch64
, x64
, etc..
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.
done
cdb4d33
to
b2e191c
Compare
Just a heads up, I tried compiling the same locally on Mac but ran into the same issue as the buildbots. |
The build errors are happening because this needs to be combined with a roll to flutter/buildroot#211 |
b2e191c
to
42a1bde
Compare
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.
42a1bde
to
a5ba655
Compare
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