Skip to content

Update device discovery to take current project into consideration. #30724

Closed

Description

@jonahwilliams

If I have an android and iOS device connected and I flutter run in a project with no ios/ directory, I should only run on the iOS device. Likewise, if I flutter run on a macOS host machine with no macos/ desktop folder, the desktop device should not compete with whatever else I have connected.

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Apr 8, 2019
  2. stuartmorgan-g commented on Apr 8, 2019

    @stuartmorgan-g
    Contributor

    Do IDEs actually do flutter devices checks within the context of a project currently? It seems like this might require changes to each IDE's Flutter support.

  3. jonahwilliams commented on Apr 8, 2019

    @jonahwilliams
    ContributorAuthor

    Good point, cc @DanTup and @devoncarew, @DaveShuckerow for IDE considerations.

    We could add a new state to a device, call it "active" when it is contained in a project that has the right device/ or .device support. A device in the normal "available" state would show up in flutter devices, but couldn't be used to flutter run.

  4. DanTup commented on Apr 8, 2019

    @DanTup
    Contributor

    In VS Code we run flutter daemon to get a list of devices and updates when they connect/disconnect. We let the user select between them (and automatically select any newly-connected device).

    Then, when running an app, if there is no current device, we'll use getEmulators to get a list of emulators (Android + iOS Simulator) and ask the user which one to launch (or if they want to create a new one), and then pass the selected devices ID to flutter run.

    If flutter daemon filtered the devices it presented based on the project type, things will probably just work?

  5. devoncarew commented on Apr 8, 2019

    @devoncarew
    Contributor

    For IntelliJ, we'll have one flutter daemon device lister running for the life of an IDE window. That window can correspond to several flutter projects.

    I don't think filtering devices by project work work for us here. I think perhaps good feedback on a flutter run could work instead? We could fail with an error message - no ios/ support enabled for project; to enable it, run 'flutter create --foo-bar ....

  6. jonahwilliams commented on Apr 8, 2019

    @jonahwilliams
    ContributorAuthor

    Longer-term, the problem we'd like to avoid here command-line users having to always manually specify a device id for Android/iOS users when desktop & web are stable. It sounds like for the IDE use cases, this isn't really an issue since the user has a UI to select the device type.

    Another approach would be to treat the devices as normal, but in the event of an ambiguous flutter run from the command line, automatically filter out desktop and web devices.

  7. DanTup commented on Apr 8, 2019

    @DanTup
    Contributor

    For IntelliJ, we'll have one flutter daemon device lister running for the life of an IDE window. That window can correspond to several flutter projects.

    Oops, I totally forgot that the daemon isn't started in the context of a project. It's the same for VS Code - we have one per-window, but a window can have multiple Flutter projects in it (eg. multi-root workspace).

    I think there needs to be a way for editors to filter a list of (all) devices to only those applicable for any given project. What if flutter daemon/devices had a platform associated with each device (ios, android, desktop, web) and there was a way for editors to tell which platforms a project is able to launch on (either as a command, or some simple logic - like the presence of platform-specific folders)? That way we can filter the list of devices when launching to those that are valid for the project being launched, and flutter run can just do what it is today, but filtering the devices in the same way?

  8. jonahwilliams commented on Apr 8, 2019

    @jonahwilliams
    ContributorAuthor

    Each device does have a target platform associated with it already, but there is no generic API for "does this project support X device type". It sounds like this is the missing feature for the IDE and command line.

  9. self-assigned this
    on Apr 8, 2019
  10. DanTup commented on Apr 10, 2019

    @DanTup
    Contributor

    but there is no generic API for "does this project support X device type".

    Yeah, something like that would be good. It'd be nice if we could filter the full list for a given project too, so if the check is expensive, rather than repeatedly checking each device, we can just ask "what device types can this project run on?" and then filter the list we have from the device daemon.

  11. Hixie commented on Apr 22, 2019

    @Hixie
    Contributor

    Long term, I would expect flutter run -d localhost on a macOS box in a project with only an android folder to create a macos/ directory and run it on the local host.

    Similarly, flutter run -d iphone in a project with only an android folder but with an iphone attached should create an ios directory and run it on the phone.

    IMHO running flutter run with no -d should "do the right thing" given the history of the user's behaviour on this project and the currently available devices. One of those options might be to launch in a browser or launch a desktop build, even if that's never happened before.

  12. stuartmorgan-g commented on Apr 23, 2019

    @stuartmorgan-g
    Contributor

    Given the way the IDE device management works, it seems like deciding what options to provide, whether to use a heuristic and if so which one, etc. would all be up to each front-end, in which case the functionality of querying which targets a platform is currently configured for would still be useful, as that would be a likely input into the decision.

  13. DaveShuckerow commented on Apr 23, 2019

    @DaveShuckerow
    Contributor

    If we want to have a consistent experience across IntellIJ/AS, VSCode and other editors, then we want the device discovery API to suggest all the platforms you could run your app on.

    ie, if the canonical way of adding iOS support to your project and running on iOS became flutter run -d iphone, then we want the discovery API to provide the IDE with -d iphone as an option for run configurations.

    For IDE usability, I agree with Devon that simply providing an error message when a platform is requested but has not been set up is the most failure-proof.

    For CLI usability, Jonah, I think we need to scale back the scope of the problem and only solve the case where there is a flutter run call with no specified device. In that case, we can look at the project configuration and the device list and figure out the right way to try to run the app.

  14. jonahwilliams commented on Apr 23, 2019

    @jonahwilliams
    ContributorAuthor

    I agree with the above - we can leave more specific UX to the frontends. We can solve the ambiguous flutter run from the command line here and add support for the query "what devices does this project support" later

  15. github-actions commented on Aug 30, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  16. locked as resolved and limited conversation to collaborators on Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

toolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions