Skip to content

Support native view screenshot in e2e integration tests #83856

Closed

Description

@blasten

Integration tests currently returns a Skia raster image.
This is fine for Flutter widgets, but it misses platform views.

As a result, customer: money or dream cannot test platform views.
Plugins like google_mobile_ads cannot have their own driver tests
that ensure that the native view is sized properly, etc...

We also happen to have the scenario app in the engine, which has
a workaround for this limitation. This workaround breaks occasionally,
and doesn't work with Skia Gold.

For all of these issues, I propose adding a new API to Flutter drive that takes the
device's screenshot and crops the status or action bars if needed
(This will be required on Android if adb is used).

cc @dnfield, @xster, @jmagman for iOS too.

Related bug: http://b/180715355

Activity

  1. dnfield commented on Jun 3, 2021

    @dnfield
    Contributor

    How will we deal with synchronization issues?

  2. blasten commented on Jun 3, 2021

    @blasten
    Author

    what is an example of a "synchronization issue" ?

  3. dnfield commented on Jun 3, 2021

    @dnfield
    Contributor

    Making sure the platform view has finished loading/animating before taking a screenshot

  4. blasten commented on Jun 3, 2021

    @blasten
    Author

    oh I see. If SurfaceView is used android.view.Choreographer cannot be used. If FlutterImageView is used, we could schedule the screenshot the next Android frame. Luckily, this is already the case with platform views that use HC.

  5. added
    P1High-priority issues at the top of the work list
    on Jun 3, 2021
  6. blasten commented on Jun 3, 2021

    @blasten
    Author

    Also, at this time we have merged the threads, so the raster and the platform threads are the same.

    I was looking at the 2s delay described in the public docs. I think if we get the next frame callback from the platform, and the raster and platform threads are merged, we should be able to remove the 2s if wanted to.

    On Android at least, the only issue is that SurfaceView/SurfaceTextureView aren't synchronized to the Android view hierarchy.

  7. jiahaog commented on Jun 3, 2021

    @jiahaog
    Member

    adding a new API to Flutter drive

    Is this going to be an API on the Flutter Driver host tools or within the Flutter Driver extension? The latter would be preferable so that it can be reused for package:integration_test as well.

  8. jmagman commented on Jun 3, 2021

    @jmagman
    Member

    I added flutter drive --screenshot to the tool in #78822 but it only fires when drive fails. They are uploaded in our LUCI tests.
    For example: https://ci.chromium.org/p/flutter/builders/prod/Mac_ios%20integration_ui_ios_textfield/1060
    Screen Shot 2021-06-03 at 10 11 28 AM
    Shows the device looked like this when it failed:

    drive_01-2

  9. jmagman commented on Jun 4, 2021

    @jmagman
    Member

    I added flutter drive --screenshot to the tool in #78822 but it only fires when drive fails. They are uploaded in our LUCI tests.

    @blasten in light of this, what additional functionality is this feature tracking?

  10. blasten commented on Jun 4, 2021

    @blasten
    Author

    oh flutter drive --screenshot is more for debugging, right? This is tracking an API that can generate images from a driver test to use as baseline for future invocations of the test.

  11. jmagman commented on Jun 4, 2021

    @jmagman
    Member

    oh flutter drive --screenshot is more for debugging, right? This is tracking an API that can generate images from a driver test to use as baseline for future invocations of the test.

    If you want the platform views/keyboards, etc it should work. --screenshot is using the tool's platform-specific flutter screenshot logic, so uses adb, idevicescreenshot, fuchsia's screencap, custom device registered hooks, etc.

    It doesn't have your "crops the status or action bars if needed" feature, though (not sure how that would work). As long as the same simulator version is used every time to compare goldens you probably don't need to crop it (that's what the scenario app does). I may be missing some additional features though.

    One thing that would be really nice is for the test itself to be able to trigger screenshots or screen recordings (tap button, screenshot, start screen recording, scroll, stop screen recording, tap button, screenshot), which would maybe would involve a VM service hook the tool responds to? Not sure...

  12. 8 remaining items

  13. blasten commented on Jun 7, 2021

    @blasten
    Author

    So I want to make sure we're not adding features to the thing we're trying to reduce the usage of 🙂

    Sounds good.

    On a separate note, flutter-team-archive/engine#26602 could use this feature. Once we increase API level coverage, we will be able to ensure that input focus and keyboard interactions work as expected.

  14. blasten commented on Jun 12, 2021

    @blasten
    Author

    #56591 appears to be a blocker for this. Currently, Gradle test-only dependencies end up in the release APK. cc @jonahwilliams

  15. jonahwilliams commented on Jun 12, 2021

    @jonahwilliams
    Contributor

    I don't see why #56591 would be a blocker - assuming you're already using the integrtion_test package then you already have that problem?

  16. blasten commented on Jun 14, 2021

    @blasten
    Author

    assuming you're already using the integrtion_test package then you already have that problem?

    Right. The release APK contains test-only dependencies as seen below.

    Screen Shot 2021-06-14 at 10 46 48 AM

    AGP has a configuration (androidTestImplementation) that generates different dependency graphs depending on the task, but it requires a different directory layout than the one used by plugins public APIs. e.g. androidTest/java, etc...

  17. Sunbreak commented on Aug 6, 2021

    @Sunbreak
    Contributor

    A lot of related issues are locked: #25306

    Do we have any progress here?

  18. tvolkert commented on Aug 6, 2021

    @tvolkert
    Contributor

    @Sunbreak this is actively being worked on.

  19. added
    f: integration_testThe flutter/packages/integration_test plugin
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Jan 25, 2022
  20. Pulkit07 commented on Mar 11, 2022

    @Pulkit07

    Hey, we are looking to take screenshots of camera view using screenshot plugin but are unable to do so because of this issue. Are there any updates on this?

    Thanks for all the work and amazing framework!

  21. jmagman commented on Mar 18, 2022

    @jmagman
    Member
  22. blasten commented on Mar 19, 2022

    @blasten
    Author

    do you know what is still needed for this feature?

    This is functional on Android. As far as Android support is concerned, this is done.
    Unless there's anything pending from iOS, this issue can be closed.

    We are tracking another issue #97853 about adding tests that need this e2e screenshot functionality.

    @Pulkit07 what issue did you run into?

  23. github-actions commented on Apr 2, 2022

    @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.

  24. locked as resolved and limited conversation to collaborators on Apr 2, 2022
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

    P1High-priority issues at the top of the work listcustomer: dream (g3)customer: googleVarious Google teamscustomer: money (g3)f: integration_testThe flutter/packages/integration_test pluginframeworkflutter/packages/flutter repository. See also f: labels.t: flutter driver"flutter driver", flutter_drive, or a driver test

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions