Skip to content

Screenshot support in impeller for AI tooling #170357

Open

Description

@jakemac53

Use case

The upcoming Dart MCP server wants to be able to expose screenshotting capability to LLMs through an MCP tool. There are many potential use cases:

  • Allow the LLM to validate its changes visually (if you ask to change the color of a button, after hot reloading did the color actually change as expected?).
  • Prompt the LLM to improve the visual style of your app, this allows it to see what it currently looks like in order to suggest changes.
  • Allows you to ask the LLM to edit something by describing it visually, it can screenshot the current page to understand which thing you are talking about.

Proposal

We should have a VM service method that can reliably take screenshots on any device, probably the _flutter.screenshot extension method. This would allow us to take screenshots for a specific app on any device.

Current state

Calling the _flutter.screenshot VM service method (the non-skia specific extension), returns _flutter.screenshot: (-32000) Could not capture image screenshot.

Similarly, running flutter screenshot --type device --vm-service-url <url> currently crashes with:

Oops; flutter has exited unexpectedly: "_flutter.screenshotSkp: (-32000) Cannot capture SKP screenshot with Impeller enabled.".

This is using a different extension method that seems skia specific, if we do get impeller support we might want to change this tool to invoke the more general version.

Ideally, one of these would be implemented on impeller (the former one doesn't say specifically that it is an impeller issue but I think it likely is?).

Why not device screenshots?

The upcoming Dart MCP server links up to your apps by VM service URI, and doesn't know the device type, so --type device isn't a great option (we would have to guess the device type or list all devices and require the user to select the device type).

Today, we only get screenshot support through the vm service method by default on desktop devices though, so that means the AI can't validate its changes visually any other device.

Other options

Get device name over VM service

We could potentially do a device screenshot if we could get the device name over the vm service, so possibly flutter tool could register an extension method to get the device id? This might be a simpler solution if it is challenging to implement screenshots on impeller.

Take device screenshots but identified by VM service URI

Alternatively, the flutter screenshot command could be able to take device screenshots, but for a specific app identified by its VM service URI, instead of a device ID.

cc @gaaclarke @kenzieschmoll

Activity

  1. added
    e: impellerImpeller rendering backend issues and features requests
    on Jun 10, 2025
  2. jonahwilliams commented on Jun 10, 2025

    @jonahwilliams
    Contributor

    SKP is an internal skia picture format (draw Rect with color, saveLayer, restore) , we wired it up for debugging shader compilation jank issues.

    I would highly recommend using a Flutter Tool mediated vm service method that takes a screenshot through the existing mechanisms and then reads the bytes off the file system.

  3. jakemac53 commented on Jun 10, 2025

    @jakemac53
    ContributorAuthor

    SKP is an internal skia picture format (draw Rect with color, saveLayer, restore) , we wired it up for debugging shader compilation jank issues.

    I updated the proposal - we actually use the _flutter.screenshot extension method today which should be more general. It is my understanding that eventually impeller will need this support anyways in order to support golden testing.

    I would highly recommend using a Flutter Tool mediated vm service method that takes a screenshot through the existing mechanisms and then reads the bytes off the file system.

    I am not generally opposed to this - it is the path I initially went down - the problem is that we have just a VM service connection, and don't have a way to call flutter screenshot and reliably get a screenshot for the device that corresponds to that connection specifically. We don't know which device to choose, and in the case of multiple apps connected to the same device (assuming this is possible), I don't think we have any way to select the correct one.

    See my "other options" section which does include two possible alternatives that would allow us to go through the flutter screenshot command.

  4. jakemac53 commented on Jun 10, 2025

    @jakemac53
    ContributorAuthor

    Actually, it looks like there is a common DTD event that does give us the device ID (see EditorDebugSession here). However, I think we are planning to move away from this API, cc @kenzieschmoll I can't recall if the newer VM service registry will contain this similar info?

  5. jonahwilliams commented on Jun 10, 2025

    @jonahwilliams
    Contributor

    Its possible to make the regular screenshot work. There are two caveats: 1) we can never give you the pixels from a platform view (those would show up empty) and 2) its unclear how it works with multiview.

    If neither of those are blockers then implementing this API is possible

  6. jakemac53 commented on Jun 10, 2025

    @jakemac53
    ContributorAuthor

    Those are good points - I assume a device screenshot would capture everything on screen including platform views.

    Not sure what it means for multi-window in general - or what a device screenshot means for desktop (whole desktop?) or browser devices (entire browser window?).

  7. jonahwilliams commented on Jun 10, 2025

    @jonahwilliams
    Contributor

    I think for desktop we just capture the main window. For browser I forgot how it works :)

  8. jakemac53 commented on Jun 10, 2025

    @jakemac53
    ContributorAuthor

    I suppose that maybe the MCP tool should actually expose both options - device screenshots and flutter screenshots? Similar to how the flutter tool works.

  9. added
    in triagePresently being triaged by the triage team
    c: proposalA detailed proposal for a change to Flutter
    engineflutter/engine related. See also e: labels.
    c: new featureNothing broken; request for a new capability
    and removed
    in triagePresently being triaged by the triage team
    on Jun 11, 2025
  10. jakemac53 commented on Jun 11, 2025

    @jakemac53
    ContributorAuthor

    Although, I realize now that device screenshots might be a bit sketchy in terms of what they might capture - especially in terms of the desktop device, but also other devices, especially if we aren't sure its going to capture the correct screen/tab/whatever.

  11. added
    P2Important issues not at the top of the work list
    on Jun 16, 2025
  12. jakemac53 commented on Jun 27, 2025

    @jakemac53
    ContributorAuthor

    Especially in the face of issues like this one - the idea of an unsuspecting user leaking a screenshot of their entire desktop or device is fairly scary. It is a lot less scary imo if it is just the flutter app pixels - although certainly still not ideal if that were to happen.

  13. sethladd commented on Oct 31, 2025

    @sethladd
    Contributor

    did we ever find a workaround to feed a screenshot from the running app into the coding agent?

  14. jakemac53 commented on Nov 3, 2025

    @jakemac53
    ContributorAuthor

    We are currently using flutter_driver to do this which seems to work on all platforms, but requires you to set up a flutter_driver entry point for your app

  15. sethladd commented on Nov 3, 2025

    @sethladd
    Contributor

    We are currently using flutter_driver to do this which seems to work on all platforms, but requires you to set up a flutter_driver entry point for your app

    thanks for confirming. Having to setup a flutter_driver entry point is less than ideal, but it does work.

    I found some other MCP servers that do enable screenshots of mobile devices, I can try those.

  16. jakemac53 commented on Nov 4, 2025

    @jakemac53
    ContributorAuthor

    I found some other MCP servers that do enable screenshots of mobile devices, I can try those.

    This is fine if you just care about the devices that those support etc - but I think for the dart/flutter MCP server itself the primary goal is supporting all devices, so it works for all users regardless of their target device. For this purpose, flutter_driver seems to be the best right now.

    But, resolving this issue would unlock the ability to use the screenshot extension method without going through flutter driver, no matter the renderer that is used (skia/impeller).

  17. AriaShishegaran commented on Nov 21, 2025

    @AriaShishegaran

    I want to mention that in order to bring actual usefulness and superiority into the LLM-in-the-Loop thing, It needs to, imo, have a couple of other factors in which could be considered other tasks or enhancement but I believe it is worth mentioning.

    It needs to have direct access to navigating the app while having access to profiler and boundary drawings over the layout of the app, so that if for example and element is having a poor padding or nested inside other containers that are also having their own paddings added on top it can visually understand what's causing the problem.

    Navigation + Screenshots + Screenshots with Boundaries overlay + Profiler access with rich information over what's exactly happening as it is navigating provides such rich set of information that debugging becomes easy, basically turning flutter into an extremely Agent friendly framework where LLMs can actually use the information as it navigates through the app, just like Chrome Dev MCP, and read logs, profiler info, bottlenecks, performance degraders, network calls, payloads, request/responses, headers and more and address visual/logical bugs perfectly.

    I'm not fully sure how deep or available is this information already via the available tools, but what I'm sure is that auto-navigation plus screenshots is definitely missing and can add a ton of tangible value on the short and long-term especially that it increase the developer-surface for less savvy devs to dabble into Flutter since this is the one framework that does all of this out of the box.

    Navigation leads to better automated testing, screenshots provide context, overlays provide deeper visual context regarding what's going visually, and profiler provides hardware-level performance improvements that can help boost a better development scaffolding right off the bat to avoid massive refactors for less savvy users.

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

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttere: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions