Skip to content

Flutter tool should use the correct architecture when "--local-engine" is specified #132162

Description

@matanlurey

Problem

In 9489009, @zanderso reverted the Flutter engine, which in turn, meant that my engine and framework versions became out of sync locally when working on a branch. This problem was surfaced when using flutter run (note, fl is a local alias for "my checkout of $FRAMEWORK"):

$ fl run \
  --local-engine-src-path=$ENGINE \
  --local-engine=android_debug_unopt_arm64 \
  --enable-impeller

Launching lib/main.dart on Pixel 5 in debug mode...
Unhandled exception:
Unexpected Kernel Format Version 107 (expected 106)
#0      BinaryBuilder.readComponent.<anonymous closure>
(package:kernel/binary/ast_from_binary.dart:691:9)

After some debugging and help, I learned this can happen when the "host" (read: where frontend_server is running)'s SDK is different than the "device" (read: my Pixel 5, in this case). However, it was really difficult for me to fix this until Jonah pointed out the tool is likely always using host_debug_unopt when --local-engine is provided, and I was building host_debug_unopt_arm64.

Proposal

Add a flag, --local-engine-use-correct-arch (or a better name), that, when set, uses (for example) host_debug_unopt_arm64 (in other words, avoids using Rosetta). After a period of time (TBD), we could flip the default and instruct engine developers they should be building and using host_debug_unopt_arm64, and eventually remove the flag.

Example:

$ fl run \
  --local-engine-src-path=$ENGINE \
  --local-engine=android_debug_unopt_arm64 \
  --local-engine-use-correct-arch \
  --enable-impeller

Alternatives

  1. Provide a --local-engine-host (this doesn't solve the problem of having the correct default)
  2. Provide a better error message when the host and device SDKs are out of sync (this doesn't let me use the arm64 host)

/cc @christopherfujino @jonahwilliams


I'd be happy to contribute a feature or fix once we reach consensus.

Activity

  1. added
    c: proposalA detailed proposal for a change to Flutter
    team-toolOwned by Flutter Tool team
    on Aug 8, 2023
  2. zanderso commented on Aug 8, 2023

    @zanderso
    Member

    I wonder if we should do alternative (1), make the flag required, and remove the logic to guess the host engine? The logic to guess the host engine has never worked quite right, iirc. Engine devs are the main users of these flags, so we should probably also gather thoughts from more engine folks.

  3. matanlurey commented on Aug 8, 2023

    @matanlurey
    ContributorAuthor

    I'm a fan of alternative (1), though selfishly I'd like the default to still work and ideally be the right default.

  4. jonahwilliams commented on Aug 8, 2023

    @jonahwilliams
    Contributor

    After an initial learning curve, I think just specifying both the local engine and the local engine host would be fine.

  5. christopherfujino commented on Aug 8, 2023

    @christopherfujino
    Contributor

    This is a duplicate of #117412, but I'll close that one since this has more detail and discussion of proposed solution.

  6. christopherfujino commented on Aug 8, 2023

    @christopherfujino
    Contributor

    alternative 1 sounds best to me.

  7. matanlurey commented on Aug 8, 2023

    @matanlurey
    ContributorAuthor

    Cool, if you're OK with it (I want to give @gaaclarke a chance to weigh in since he filed the original issue), I can take a shot!

  8. self-assigned this
    on Aug 8, 2023
  9. gaaclarke commented on Aug 9, 2023

    @gaaclarke
    Member

    #117412 is slightly different since I was building for macOS so the argument was --local-engine=host_debug_unopt_arm64, but the interpretation is --local-engine=host_debug_unopt which is clearly wrong and doesn't need the same considerations as when you are cross-compiling.

    I'm not as concerned about breaking workflows. Unfortunately there is documentation written about how to use a custom engine in flutter, some of it not under our control. So, adding new flags is breaking all of that, which could be just as bad.

    Alternative 3 is Matan's proposal without any transition period or temporary flag (imagine me saying "temporary" in a slimy contemptuous way like Alan Rickman). His idea of having a better warning if using mixmatched local and remote engines is a good one and could remedy any place where a change in the default behavior could lead to problems.

  10. github-actions commented on Aug 24, 2023

    @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.

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

Metadata

Metadata

Assignees

Labels

c: proposalA detailed proposal for a change to Flutterfyi-engineFor the attention of Engine teamteam-toolOwned by Flutter Tool team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions