Skip to content

[Android] Wire command line shell arguments to the embedding through the manifest instead of an Intent#180591

Open
camsim99 wants to merge 120 commits into
flutter:masterfrom
camsim99:engine_args_tool
Open

[Android] Wire command line shell arguments to the embedding through the manifest instead of an Intent#180591
camsim99 wants to merge 120 commits into
flutter:masterfrom
camsim99:engine_args_tool

Conversation

@camsim99

@camsim99 camsim99 commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Modifies the way that the Flutter tool sends command line flags to the embedding to eliminate the pre-existing dependence on passing them via Intent extras.

Specifically, this PR modifies the tool to (1) encode the flags into JSON, (2) create an extra manifest file that encode that JSON as manifest metadata via a custom Gradle task, and (3) instructs Gradle to merge that generated manifest into the final produced manifest. On the Flutter Android embedding side, the flags are decoded from JSON and loaded as before.

Note

This PR is technically a breaking change because users of the --use-application-binary flag wishing to avoid rebuilding the APK will get their APK rebuilt if the flags have changed between running that APK.

This is required with this approach because the flags are encoded in the manifest, so the manifest will have to be regenerated if the flags change. This will not require any action from the developer and a warning will be printed if the APK has to be rebuilt against their wishes.

A quick test of the time it take to render the first Flutter frame when using --use-application-binary demonstrates that this change is not the bottleneck when running prebuilt APKs:

Test Case Time before this change (micros) Time with this change (micros)
Running app with one flag after running with none 743708 721116
Running app with three flags after running with none 710815 760421
Running app with three flags after running with two flags the same, one different 844228 756930

For more context, see the one-pager for this design go/flutter-android-no-more-intents. Part of #180686.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions Bot added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Jan 6, 2026
@github-actions github-actions Bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: gestures flutter/packages/flutter/gestures repository. platform-web Web applications specifically package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team c: tech-debt Technical debt, code quality, testing, etc. e: impeller Impeller rendering backend issues and features requests d: docs/ flutter/flutter/docs, for contributors and removed a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: gestures flutter/packages/flutter/gestures repository. platform-web Web applications specifically package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team c: tech-debt Technical debt, code quality, testing, etc. labels Mar 2, 2026
gmackall
gmackall previously approved these changes May 5, 2026

@gmackall gmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm outside of route question

'enable-hcpp-and-surface-control',
'true',
],
if (route != null) ...<String>['--route=$route'],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this not need the "es" from before?

if (route != null) ...<String>['--es', 'route', route],

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. Will fix and make sure a test case covers this.

@camsim99

camsim99 commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

TODO: handle #186359 if it lands first. Also make sure this does not impact #186298

Done. #186359 not landed yet at the time of this comment.

gmackall
gmackall previously approved these changes Jun 1, 2026

@gmackall gmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@flutter-dashboard

Copy link
Copy Markdown

CI had a failure that stopped further tests from running. We need to investigate to determine the root cause.

SHA at time of execution: b434745.

Possible causes:

  • Configuration Changes: The .ci.yaml file might have been modified between the creation of this pull request and the start of this test run. This can lead to ci yaml validation errors.
  • Infrastructure Issues: Problems with the CI environment itself (e.g., quota) could have caused the failure.

A blank commit, or merging to head, will be required to resume running CI for this PR.

Error Details:

DetailedApiRequestError(status: 409, message: Document already exists: projects/flutter-dashboard/databases/cocoon/documents/presubmit_jobs/flutter_flutter_79785541668_Linux engine_dependency_proxy_test_1)

Stack trace:

#0      validateResponse (package:_discoveryapis_commons/src/api_requester.dart:306:9)
<asynchronous suspension>
#1      ApiRequester.request (package:_discoveryapis_commons/src/api_requester.dart:72:16)
<asynchronous suspension>
#2      ProjectsDatabasesDocumentsResource.commit (package:googleapis/firestore/v1.dart:1278:23)
<asynchronous suspension>
#3      UnifiedCheckRun.initializeCiStagingDocument (package:cocoon_service/src/service/firestore/unified_check_run.dart:71:7)
<asynchronous suspension>
#4      Scheduler._runCiTestingStage (package:cocoon_service/src/service/scheduler.dart:1437:9)
<asynchronous suspension>
#5      Scheduler.proceedToCiTestingStage (package:cocoon_service/src/service/scheduler.dart:1519:7)
<asynchronous suspension>
#6      Scheduler._closeSuccessfulEngineBuildStage (package:cocoon_service/src/service/scheduler.dart:1333:5)
<asynchronous suspension>
#7      Scheduler.processCheckRunCompleted (package:cocoon_service/src/service/scheduler.dart:1265:11)
<asynchronous suspension>
#8      PresubmitLuciSubscription.post (package:cocoon_service/src/request_handlers/presubmit_luci_subscription.dart:176:9)
<asynchronous suspension>
#9      RequestHandler.service (package:cocoon_service/src/request_handling/request_handler.dart:42:20)
<asynchronous suspension>
#10     SubscriptionHandler.service (package:cocoon_service/src/request_handling/subscription_handler.dart:139:5)
<asynchronous suspension>
#11     createServer.<anonymous closure> (package:cocoon_service/server.dart:448:7)
<asynchronous suspension>
#12     main.<anonymous closure>.<anonymous closure> (file:///app/app_dart/bin/gae_server.dart:187:9)
<asynchronous suspension>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants