Skip to content

(Flutter) Allow cold boot launch using vs code command #3366

Closed

Description

@Hamdor

Is your feature request related to a problem? Please describe.
Sometimes it is necessary to fully boot the android based emulator (e.g. system buttons do not work). To fix the problem, the emulator instance needs a complete reboot.
A recent change to the flutter tooling is, that we can now cold boot android based emulators with an additional flag (--cold) which can be added to the --launch flag. (see flutter/flutter#82647)

Describe the solution you'd like
I would like an additional prompt that asks the user after emulator selection if it should be cold bootet ("yes" or "no", defaulting to "no").
In addition, the prompt will only be shown for android based emulators, since it is only available for android.

Describe alternatives you've considered
Alternative approach: A distinct command could be used (e.g. "Cold Launch Emulator"). Then no "yes" or "no" prompt would be shown.

Additional context

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on May 26, 2021
  2. DanTup commented on May 26, 2021

    @DanTup
    Member

    I'm not sure I'd like to add an additional prompt (it would be an unnecessary step for the majority of the time), but perhaps we can list the emulator in the device selector twice, once with a "(cold boot)" suffix that would then pass this flag?

    We should only show it if the Flutter SDK version supports the flag, and ofc only for android-based emulators.

  3. added this to the v3.24.0 milestone on May 26, 2021
  4. Hamdor commented on May 26, 2021

    @Hamdor
    ContributorAuthor

    The double listing is also a good idea. If you want I can try to implement that feature request.

  5. DanTup commented on May 26, 2021

    @DanTup
    Member

    That would be great!

    The code the manages getting emulators etc. is in src/shared/vscode/device_manager.ts and the version numbers for checking capabilities go into src/shared/capabilities/flutter.ts. Related tests are in src/test/flutter/device_manager.test.ts (we should check that Android emulators get the extra option, but something else like iOS Simulator does not).

  6. Hamdor commented on May 27, 2021

    @Hamdor
    ContributorAuthor

    @DanTup, I saw that the extension uses the flutter daemon to launch emulators, but I assume that it does not support the cold boot[1]. The flag was added to the command line interface only. Do you think it would cause problems, if we use the command line interface instead of the daemon in case of cold boot selection?

    [1] https://github.com/flutter/flutter/blob/b8a2456737c9645e5f3d7210fba6267f7408486f/packages/flutter_tools/lib/src/commands/daemon.dart#L1119

  7. DanTup commented on May 27, 2021

    @DanTup
    Member

    Ah, good spot. It looks like that will first need updating in Flutter to support passing an argument then (and the docs here updating). I don't think switching to the command line is the best idea, we try to stick to structured APIs so that it's easier to return additional information/errors etc. which are much harder to handle from the editor if they're just text designed for users.

  8. Hamdor commented on May 27, 2021

    @Hamdor
    ContributorAuthor

    I created a feature request for that in the flutter repository here: flutter/flutter#83471

  9. DanTup commented on May 27, 2021

    @DanTup
    Member

    Thanks! Let me know if you're planning to contribute it there - if not, I can take a look. Thanks!

  10. Hamdor commented on May 27, 2021

    @Hamdor
    ContributorAuthor

    I will contribute a pull request to flutter, should be no big change

  11. Hamdor commented on Jun 2, 2021

    @Hamdor
    ContributorAuthor

    @DanTup, I tried to run some tests but for some reason later tests are failing with an error message from vs code: "Build errors exist in your project". It seems like the dart/flutter test projects are broken
    Is it somehow possible to run selective tests only?

    Here is the terminal output from the failing tests:

    Running dart_debug tests folder in workspace hello_world
    Attempting to download VS Code attempt #1
    Found .vscode-test/vscode-win32-archive-1.56.2. Skipping download.
    Running tests with pre-downloaded VS Code
    Found .vscode-test/vscode-win32-archive-1.56.2. Skipping download.
    
    
    Warning: 'sandbox' is not in the list of known options, but still passed to Electron/Chromium.
    
    [main 2021-06-02T15:19:13.696Z] update#setState idle
    
    (node:19404) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    (Use `Code --trace-deprecation ...` to show where the warning was created)
    
    Starting test runner...
    
    
    
    (node:19404) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pass listeners added to [Runner]. Use emitter.setMaxListeners() to increase limit
    
    (node:19404) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 fail listeners added to [Runner]. Use emitter.setMaxListeners() to increase limit
    
      dart cli debugger
    
    [17:19:18] [General] [Warn] Project has errors, prompting user
    
    [17:19:18] [General] [Warn]     C:\Users\mtrie\gitrepos\Dart-Code\src\test\test_projects\hello_world\bin\deferred_entry.dart:0:7
    
    [17:19:18] [General] [Warn]     Target of URI doesn't exist: 'package:hello_world/deferred_script.dart'.
    
    [main 2021-06-02T15:19:43.701Z] update#setState checking for updates
    
    [main 2021-06-02T15:19:43.735Z] update#setState idle
    
        1) runs to completion
    
  12. DanTup commented on Jun 2, 2021

    @DanTup
    Member

    @Hamdor it looks like you might be trying to run the Dart Debug tests, but probably you want to run just the Flutter tests. The best way to do this is selecting the Flutter Tests item in drop-down from the VS Code side bar and then running with F5/the green play button.

    You can run individual tests by changing it("test name" to it.only("test name in the code (it's the Mocha framework being used).

    The specific error stopping the Dart Debug tests from running is that you haven't run "pub get" in the test_projects\hello_world folder. You don't need to do this if you're not running those tests, though usually I open the entire test_projects folder in a VS Code window and accept when it asks to run pub get for all projects - that fetches the dependencies for all of the test projects that may be used in tests.

  13. Hamdor commented on Jun 2, 2021

    @Hamdor
    ContributorAuthor

    Thanks, that helps. I tried to just run "npm test" from terminal.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in flutterRelates to running Flutter appsis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions