Skip to content

Conversation

vashworth
Copy link
Contributor

@vashworth vashworth commented Nov 3, 2022

Add more supported simulator debugging options update tests. Also, add tests for other launch arguments.

Fixes #52676.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

@flutter-dashboard flutter-dashboard bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. labels Nov 3, 2022
@vashworth
Copy link
Contributor Author

Discussed with @jmagman about improving this code by using a single function that returns the list of launch arguments that can then be used for both the iOS simulator and physical iOS. The upside of this would be less repeated code, and if someone wants to add a new flag in the future, they can add to just one place and won't have to remember to add to both simulators.dart and devices.dart.

@vashworth
Copy link
Contributor Author

Also discussed how the simulator version only adds the flags if the debuggingOptions.debuggingEnabled is true

if (debuggingOptions.debuggingEnabled) ...<String>[
if (debuggingOptions.buildInfo.isDebug) ...<String>[
'--enable-checked-mode',
'--verify-entry-points',
],
if (debuggingOptions.enableSoftwareRendering) '--enable-software-rendering',
if (debuggingOptions.startPaused) '--start-paused',
if (debuggingOptions.disableServiceAuthCodes) '--disable-service-auth-codes',
if (debuggingOptions.skiaDeterministicRendering) '--skia-deterministic-rendering',
if (debuggingOptions.useTestFonts) '--use-test-fonts',
if (debuggingOptions.traceAllowlist != null) '--trace-allowlist="${debuggingOptions.traceAllowlist}"',
if (debuggingOptions.traceSkiaAllowlist != null) '--trace-skia-allowlist="${debuggingOptions.traceSkiaAllowlist}"',
if (dartVmFlags.isNotEmpty) '--dart-flags=$dartVmFlags',
if (debuggingOptions.enableImpeller) '--enable-impeller',
'--observatory-port=${debuggingOptions.hostVmServicePort ?? 0}',
if (route != null) '--route=$route',
],

Whereas the device version adds them regardless, and only adds 2 specific ones if debuggingOptions.debuggingEnabled is true.

if (debuggingOptions.debuggingEnabled) ...<String>[
'--enable-checked-mode',
'--verify-entry-points',
],
if (debuggingOptions.enableSoftwareRendering) '--enable-software-rendering',

Since the iOS simulator only runs in debug mode (profile and release mode are not supported), we think it's okay to remove the debuggingOptions.debuggingEnabled check for the simulator.

@vashworth vashworth marked this pull request as ready for review November 3, 2022 23:14
@vashworth vashworth requested a review from jmagman November 3, 2022 23:15
@vashworth vashworth removed the request for review from jmagman November 4, 2022 19:40
@vashworth
Copy link
Contributor Author

vashworth commented Nov 4, 2022

Note about cc03fe2.

So I've discovered that having the quotes surrounding the --dart-flags launch argument matters and differs between simulator and physical iOS devices.

if (environmentType == EnvironmentType.physical && dartVmFlags.isNotEmpty) '--dart-flags="$dartVmFlags"',
if (environmentType == EnvironmentType.simulator && dartVmFlags.isNotEmpty) '--dart-flags=$dartVmFlags',

I tested this locally by using a single check for the dart flags and tried with and without quotes.
if (dartVmFlags.isNotEmpty) '--dart-flags="$dartVmFlags"',

Command I ran flutter run --dart-flags="--max_profile_depth 255,--foo"
Expected Result: Encountered disallowed Dart VM flag: --foo

Test 1 - with quotes, physical device - PASS
Result: [VERBOSE-3:switches.cc(441)] Encountered disallowed Dart VM flag: --foo

Test 2 - with quotes, simulator device - FAIL
Result: [VERBOSE-3:switches.cc(441)] Encountered disallowed Dart VM flag: "--max_profile_depth 255

Test 3 - without quotes, physical device - FAIL
Result: Runner[781:39983] Ignoring flag: true is an invalid value for flag max_profile_depth

Test 4 - without quotes, simulator device - PASS
Result: [VERBOSE-3:switches.cc(441)] Encountered disallowed Dart VM flag: --foo

if (route != null) '--route=$route',
if (environmentType == EnvironmentType.physical && (platformArgs['trace-startup'] as bool? ?? false)) '--trace-startup',
if (enableImpeller) '--enable-impeller',
if (environmentType == EnvironmentType.simulator) '--observatory-port=${hostVmServicePort ?? 0}',
Copy link
Member

Choose a reason for hiding this comment

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

I think it can go back to the behavior in https://github.com/flutter/flutter/pull/49735/files#diff-5a3d215e39f292ac706d495f042ef45fab9f13962022f4e8e4580254e8557d52L334 and pass the port along, if it's been set:

Suggested change
if (environmentType == EnvironmentType.simulator) '--observatory-port=${hostVmServicePort ?? 0}',
if (hasObservatoryPort) '--observatory-port=${hostVmServicePort}',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this differ between simulator and physical?

Looking at that change, looks like they used deviceVmServicePort https://github.com/flutter/flutter/pull/49735/files#diff-5a3d215e39f292ac706d495f042ef45fab9f13962022f4e8e4580254e8557d52L335

Whereas it's hostVmServicePort in original simulator args

'--observatory-port=${debuggingOptions.hostVmServicePort ?? 0}',
.

Is it possible to have both a deviceVmServicePort and hostVmServicePort and if so, which should be used if both are provided?

Copy link
Member

Choose a reason for hiding this comment

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

Good question, I had to ask @jonahwilliams for clarification here, this behavior has changed over time and not every spot it's used has been kept consistent.

To quote Jonah:

  • Application runs on device, it starts up a VM Service instance. This instance will broadcast on a port + auth code combo.
  • (Optional) If Host/Device are different machines, we forward the device port to a selected host port.
  • (Optional) If dds is enabled, dds connects to the selected host port, then broadcasts on the dds port

For physical devices, the right thing to use is deviceVmServicePort. The confusion is what to do if the "device" and host are really the same, as is the case with desktop apps or the iOS simulator, because there's no need to do port forwarding if they are the same machines. So I think hostVmServicePort is correct in this case, though it's very confusing and it's likely we have some bugs in here.

@christopherfujino the host/device port logic could use cleanup, comments, better help text, perhaps variable renaming, and verification we're doing the right thing for all device types.

Copy link
Contributor

Choose a reason for hiding this comment

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

@christopherfujino the host/device port logic could use cleanup, comments, better help text, perhaps variable renaming, and verification we're doing the right thing for all device types.

Agreed, let me make a tracking issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, let me make a tracking issue.

#114845

Change --disable-service-auth-codes to not always be included for physical devices, only if disableServiceAuthCodes is true.
Change --disable-observatory-publication to be used for simulator devices too.
Change --enable-checked-mode & --verify-entry-points to be used if debuggingEnabled is true regardless of device type.
Chnage --trace-startup to be used for simulator devices too.
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

This LGTM with minor nits

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

Thanks for tracking down all the weird corner cases.

@vashworth vashworth added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 9, 2022
@auto-submit auto-submit bot merged commit 3a656b1 into flutter:master Nov 9, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Nov 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2022
auto-submit bot pushed a commit to flutter/plugins that referenced this pull request Nov 10, 2022
* 3a656b1 Add more supported simulator debugging options and improve tests (flutter/flutter#114628)

* 51c517c [flutter_tools/dap] Add support for forwarding `flutter run --machine` exposeUrl requests to the DAP client (flutter/flutter#114539)

* 8e5439c Roll Flutter Engine from e7d7edab98ad to c76035429c36 (14 revisions) (flutter/flutter#115008)

* a479718 Update cirrus key (flutter/flutter#115006)

* dccc761 Roll Flutter Engine from c76035429c36 to aa4b3ea2f733 (27 revisions) (flutter/flutter#115025)

* d0491dc Add the `channel` parameter to the Dartpad samples (flutter/flutter#115018)

* befd8b6 722414a26 Implemented threadsafe platform channel replies on windows (flutter/engine#36909) (flutter/flutter#115033)

* 154ae0f `updateSemantics` in TestWindow should always be implemented. (flutter/flutter#114857)

* 008ac17 remove unnecessary brace in string interpolation (flutter/flutter#115032)

* 8926d9e a9fbf6af5 Roll Fuchsia Linux SDK from mDzQK4ZUk_Y4wfZa_... to RNSA2Wp1MObtc7OHy... (flutter/engine#37485) (flutter/flutter#115045)

* e6fb124 Roll Flutter Engine from a9fbf6af52c9 to b42ed6933cef (2 revisions) (flutter/flutter#115048)

* ff75451 a42b2d9b9 Fix a race in the EmbedderA11yTest.A11yTreeIsConsistent tests (flutter/engine#37488) (flutter/flutter#115060)

* c7d1154 a71c0c6c3 [Impeller] Support access the descriptor of PipelineFuture directly (flutter/engine#37415) (flutter/flutter#115063)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2022
IVLIVS-III pushed a commit to IVLIVS-III/flutter_plugins_fork that referenced this pull request Nov 11, 2022
* 3a656b1 Add more supported simulator debugging options and improve tests (flutter/flutter#114628)

* 51c517c [flutter_tools/dap] Add support for forwarding `flutter run --machine` exposeUrl requests to the DAP client (flutter/flutter#114539)

* 8e5439c Roll Flutter Engine from e7d7edab98ad to c76035429c36 (14 revisions) (flutter/flutter#115008)

* a479718 Update cirrus key (flutter/flutter#115006)

* dccc761 Roll Flutter Engine from c76035429c36 to aa4b3ea2f733 (27 revisions) (flutter/flutter#115025)

* d0491dc Add the `channel` parameter to the Dartpad samples (flutter/flutter#115018)

* befd8b6 722414a26 Implemented threadsafe platform channel replies on windows (flutter/engine#36909) (flutter/flutter#115033)

* 154ae0f `updateSemantics` in TestWindow should always be implemented. (flutter/flutter#114857)

* 008ac17 remove unnecessary brace in string interpolation (flutter/flutter#115032)

* 8926d9e a9fbf6af5 Roll Fuchsia Linux SDK from mDzQK4ZUk_Y4wfZa_... to RNSA2Wp1MObtc7OHy... (flutter/engine#37485) (flutter/flutter#115045)

* e6fb124 Roll Flutter Engine from a9fbf6af52c9 to b42ed6933cef (2 revisions) (flutter/flutter#115048)

* ff75451 a42b2d9b9 Fix a race in the EmbedderA11yTest.A11yTreeIsConsistent tests (flutter/engine#37488) (flutter/flutter#115060)

* c7d1154 a71c0c6c3 [Impeller] Support access the descriptor of PipelineFuture directly (flutter/engine#37415) (flutter/flutter#115063)
adam-harwood pushed a commit to adam-harwood/flutter_plugins that referenced this pull request Nov 21, 2022
* 3a656b1 Add more supported simulator debugging options and improve tests (flutter/flutter#114628)

* 51c517c [flutter_tools/dap] Add support for forwarding `flutter run --machine` exposeUrl requests to the DAP client (flutter/flutter#114539)

* 8e5439c Roll Flutter Engine from e7d7edab98ad to c76035429c36 (14 revisions) (flutter/flutter#115008)

* a479718 Update cirrus key (flutter/flutter#115006)

* dccc761 Roll Flutter Engine from c76035429c36 to aa4b3ea2f733 (27 revisions) (flutter/flutter#115025)

* d0491dc Add the `channel` parameter to the Dartpad samples (flutter/flutter#115018)

* befd8b6 722414a26 Implemented threadsafe platform channel replies on windows (flutter/engine#36909) (flutter/flutter#115033)

* 154ae0f `updateSemantics` in TestWindow should always be implemented. (flutter/flutter#114857)

* 008ac17 remove unnecessary brace in string interpolation (flutter/flutter#115032)

* 8926d9e a9fbf6af5 Roll Fuchsia Linux SDK from mDzQK4ZUk_Y4wfZa_... to RNSA2Wp1MObtc7OHy... (flutter/engine#37485) (flutter/flutter#115045)

* e6fb124 Roll Flutter Engine from a9fbf6af52c9 to b42ed6933cef (2 revisions) (flutter/flutter#115048)

* ff75451 a42b2d9b9 Fix a race in the EmbedderA11yTest.A11yTreeIsConsistent tests (flutter/engine#37488) (flutter/flutter#115060)

* c7d1154 a71c0c6c3 [Impeller] Support access the descriptor of PipelineFuture directly (flutter/engine#37415) (flutter/flutter#115063)
shogohida pushed a commit to shogohida/flutter that referenced this pull request Dec 7, 2022
…tter#114628)

* add debugging options to simulator, test more debugging flags, add tests for other launch arguements

* refactor iOS launch arguments to use one function for both simulator and physical devices

* treat dart flags differently between physical and simulator

* Simplify some flags between devices.

Change --disable-service-auth-codes to not always be included for physical devices, only if disableServiceAuthCodes is true.
Change --disable-observatory-publication to be used for simulator devices too.
Change --enable-checked-mode & --verify-entry-points to be used if debuggingEnabled is true regardless of device type.
Chnage --trace-startup to be used for simulator devices too.

* fix ios release mode with buildable app startApp test

* determine observatory-port from deviceVmServicePort and hostVmServicePort

* add comments and remove hasObservatoryPort
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jan 19, 2023
…tter#114628)

* add debugging options to simulator, test more debugging flags, add tests for other launch arguements

* refactor iOS launch arguments to use one function for both simulator and physical devices

* treat dart flags differently between physical and simulator

* Simplify some flags between devices.

Change --disable-service-auth-codes to not always be included for physical devices, only if disableServiceAuthCodes is true.
Change --disable-observatory-publication to be used for simulator devices too.
Change --enable-checked-mode & --verify-entry-points to be used if debuggingEnabled is true regardless of device type.
Chnage --trace-startup to be used for simulator devices too.

* fix ios release mode with buildable app startApp test

* determine observatory-port from deviceVmServicePort and hostVmServicePort

* add comments and remove hasObservatoryPort
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
* 3a656b1 Add more supported simulator debugging options and improve tests (flutter/flutter#114628)

* 51c517c [flutter_tools/dap] Add support for forwarding `flutter run --machine` exposeUrl requests to the DAP client (flutter/flutter#114539)

* 8e5439c Roll Flutter Engine from e7d7edab98ad to c76035429c36 (14 revisions) (flutter/flutter#115008)

* a479718 Update cirrus key (flutter/flutter#115006)

* dccc761 Roll Flutter Engine from c76035429c36 to aa4b3ea2f733 (27 revisions) (flutter/flutter#115025)

* d0491dc Add the `channel` parameter to the Dartpad samples (flutter/flutter#115018)

* befd8b6 722414a26 Implemented threadsafe platform channel replies on windows (flutter/engine#36909) (flutter/flutter#115033)

* 154ae0f `updateSemantics` in TestWindow should always be implemented. (flutter/flutter#114857)

* 008ac17 remove unnecessary brace in string interpolation (flutter/flutter#115032)

* 8926d9e a9fbf6af5 Roll Fuchsia Linux SDK from mDzQK4ZUk_Y4wfZa_... to RNSA2Wp1MObtc7OHy... (flutter/engine#37485) (flutter/flutter#115045)

* e6fb124 Roll Flutter Engine from a9fbf6af52c9 to b42ed6933cef (2 revisions) (flutter/flutter#115048)

* ff75451 a42b2d9b9 Fix a race in the EmbedderA11yTest.A11yTreeIsConsistent tests (flutter/engine#37488) (flutter/flutter#115060)

* c7d1154 a71c0c6c3 [Impeller] Support access the descriptor of PipelineFuture directly (flutter/engine#37415) (flutter/flutter#115063)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--trace-skia not getting sent to the engine for iOS simulator
3 participants