This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Set Platform.executable on startup#33127
Merged
cbracken merged 1 commit intoflutter:mainfrom May 5, 2022
cbracken:platform-executable-embedder
Merged
Set Platform.executable on startup#33127cbracken merged 1 commit intoflutter:mainfrom cbracken:platform-executable-embedder
cbracken merged 1 commit intoflutter:mainfrom
cbracken:platform-executable-embedder
Conversation
Member
Author
|
Note that while this does fix the crash currently triggered by calling Platform.executable, it doesn't guarantee that each of the embedders is doing the right thing, and in fact macOS is currently passing a placeholder value. I have a separate followup patch that corrects the macOS behaviour. For the time being, the iOS, Android, and Fuchsia embedders will return "Flutter". This can be improved in one or more followup patches. |
jason-simmons
approved these changes
May 5, 2022
Previously, using Platform.executable (from dart:io) returned null (if non-null-by-default was disabled) or threw an exception (if NNBD was enabled) since we weren't setting it. We now pass the executable name to Dart during VM startup based on the first value in the FlutterProjectArgs::command_line_argv array passed to FlutterEngineRun (or FlutterEngineInitialize) on startup. argv[0] (if specified) is explicitly documented as being required to be the executable name in embedder.h. In the case where no argv[0] is specified, we instead set Platform.executable to "Flutter" in order to avoid violating the (non-nullable) type annoation on Platform.executable. Note that dart::bin::SetExecutableName() does NOT make a copy of the input string, so it needs to be available for the entire lifetime of the VM. This also adds EmbedderConfigBuilder::SetExecutableName() to support setting a fake executable name in unittests. By default, we continue to set the name "embedder_unittest" unless overridden using this method. See: https://api.flutter.dev/flutter/dart-io/Platform/executable.html Issue: flutter/flutter#83921
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
May 5, 2022
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
May 5, 2022
This was referenced May 6, 2022
11 tasks
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, using Platform.executable (from dart:io) returned null (if
non-null-by-default was disabled) or threw an exception (if NNBD was
enabled) since we weren't setting it.
We now pass the executable name to Dart during VM startup based on the
first value in the FlutterProjectArgs::command_line_argv array passed to
FlutterEngineRun (or FlutterEngineInitialize) on startup. argv[0] (if
specified) is explicitly documented as being required to be the
executable name in embedder.h. In the case where no argv[0] is
specified, we instead set Platform.executable to "Flutter" in order to
avoid violating the (non-nullable) type annotation on
Platform.executable.
Note that dart::bin::SetExecutableName() does NOT make a copy of the
input string, so that value needs to be available for the entire lifetime
of the VM.
This also adds EmbedderConfigBuilder::SetExecutableName() to support
setting a fake executable name in unittests. By default, we continue to
set the name "embedder_unittest" unless overridden using this method.
See: https://api.flutter.dev/flutter/dart-io/Platform/executable.html
See: dart-lang/sdk#48427
Issue: flutter/flutter#83921
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.