Skip to content

☂️ Deferred Components: Build and load split AOT Android App Bundles #57617

Closed

Description

@mehmetf

Internal: b/160378043

As detailed in dart-lang/sdk#41974, customer:money is interested in splitting their AOT code by country and by feature. Once Dart VM team provides this capability, we need changes to engine (and tooling) to be able to generate these splits and load them.

Phase 1: Install-time AOT Code Splits
This would be transparent to the app. We would load all the splits into memory when a Dart isolate gets created. This requires an engine change but no application specific API.

Phase 2: Dynamic AOT Code splits.
This would require an engine change as well which would expose a system channel to request a particular AOT split to be loaded into the isolate. It is possible that we want these asset loading that is exposed via flutter engine (FlutterLoader) to do this. FlutterLoader would access Core APIs to download the so's and then load into isolate. There's an argument to be made to extend this to any PlatformAsset; I would leave that decision to the engine team.

PS: The tooling change is lower priority from customer's point of view since we have to implement this in g3.

The following is added/tracked by @GaryQian at the top for visibility:

Tasks left TODO:

Engine:

Framework:

Tooling:

Misc:

  • Finish instructions/guide (go/flutter-split-aot-instructions)
  • Finalize naming, eg, what to call this feature ("Deferred Components")

Activity

  1. xster commented on Jun 3, 2020

    @xster
    Member

    Phase 2 relates to #51522

  2. xster commented on Jun 3, 2020

    @xster
    Member

    One clarification: for an mvp, do we need to alter the engine at all? Or is this purely a tooling thing?

    One possibility is that we create tooling and flavors or gradle flavor-like manifests in the pubspec that lists the locale mappings. When you flutter build apk --split-by-xxx, it essentially calls build apk y times but a single filtered libapp.so gets packaged into an apk. You get y apks, each with one uniquely combined libapp.so and you upload one per locale. No engine changes.

    The other possibility is that we fully adhere to the Android packaging patterns https://developer.android.com/guide/topics/resources/providing-resources#AlternativeResources and have lib-en/libflutter.so, lib-en/libcoreapp.so, lib-en/libfeatureA.so, lib-fr/libflutter.so, lib-fr/libcoreapp.so, lib-fr/libfeatureB.so etc. Engine needs to know how to load different .so.

  3. mehmetf commented on Jun 4, 2020

    @mehmetf
    ContributorAuthor

    I would not go with "single filtered libapp.so" for two reasons: It really goes against the grain both externally and internally on what Android wants us to do (as you point out) and it puts the responsibility on the user to correctly configure their play store settings to deliver the right APK.

    There might be a middle ground here for Install-time AOT Code Splits. Instead of "knowing which .so to load" based on user request, engine loader could eagerly "discover" and load all the .so's into Dart isolate when it starts (if there's some way of differentiating them from other so files in the APK). That takes lifecycle concerns out of the equation at least which is likely the biggest concern for this feature.

  4. xster commented on Jun 4, 2020

    @xster
    Member

    Ya, SG. I'm not quite advocating for either. Just trying to get more context on what they're asking for. Loading all .so's (and not initially creating more APIs to load on demand) SGTM too.

  5. added
    perf: app sizePerformance issues related to app size (binary/code size) or disk space
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    on Jun 4, 2020
  6. added this to the 1.23 - September 2020 milestone on Jun 13, 2020
  7. xster commented on Jun 14, 2020

    @xster
    Member

    When we build general support for this feature, I think it makes sense to package this under the AAB "configuration APK" mechanism for the Play Store and eventually into the "dynamic feature module" mechanism.

    https://developer.android.com/guide/app-bundle/dynamic-delivery
    https://developer.android.com/guide/app-bundle/dynamic-delivery#dynamic_feature_manifest

    Is that where g3 tooling is thinking about as well? i.e. not using APK with OOB expansions etc?

    Also cc @zoeyfan as perhaps a CAB agenda item. Since these mechanisms are Play Store specific, we should get some feedback to see if there are minor adjustments we should make to make this somehow beneficial for China customers as well. i.e. are local app store mechanisms able to handle AAB uploads with module manifests specifying delayed downloads etc?

    https://developer.android.com/guide/app-bundle/dynamic-delivery#customize_delivery

  8. 65 remaining items

  9. added
    P1High-priority issues at the top of the work list
    and removed on Feb 9, 2021
  10. Hixie commented on Feb 9, 2021

    @Hixie
    Contributor

    Google bug is now closed, hopefully that means it won't propagate priorities anymore :-)

  11. GaryQian commented on Feb 10, 2021

    @GaryQian
    Contributor

    #75739 Implements tooling setup validation.

  12. GaryQian commented on Mar 3, 2021

    @GaryQian
    Contributor

    #76192 Implements build tooling such that deferred components builds are fully functional.

  13. GaryQian commented on Mar 5, 2021

    @GaryQian
    Contributor

    #76192 Has landed, which brings full building and validation functionality to the tooling.

  14. GaryQian commented on Mar 5, 2021

    @GaryQian
    Contributor

    Remaining work is to complete documentation and optionally land cleanup/minor feature PRs:

  15. xster commented on Mar 9, 2021

    @xster
    Member

    @GaryQian can you update the milestone or close this feature bug and create derivative bugs to capture the various cleanup tasks and documentation?

  16. GaryQian commented on Mar 16, 2021

    @GaryQian
    Contributor

    Related: #78204

  17. GaryQian commented on Mar 29, 2021

    @GaryQian
    Contributor

    https://github.com/flutter/gallery/pull/461 Implements deferred components for "crane" demo in gallery

  18. GaryQian commented on Mar 30, 2021

    @GaryQian
    Contributor

    Supporting Deferred components on iOS is tracked in #79327

  19. GaryQian commented on Apr 8, 2021

    @GaryQian
    Contributor

    Closing this issue. Remaining work is iOS, tracked separately.

  20. github-actions commented on Aug 3, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  21. locked as resolved and limited conversation to collaborators on Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: new featureNothing broken; request for a new capabilityc: performanceRelates to speed or footprint issues (see "perf:" labels)customer: money (g3)engineflutter/engine related. See also e: labels.p: toolingAffects the flutter_plugin_tools packageperf: app sizePerformance issues related to app size (binary/code size) or disk spaceplatform-androidAndroid applications specifically

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions