Skip to content

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

@matanlurey

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.

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