Skip to content

Conversation

@CareF
Copy link
Contributor

@CareF CareF commented Jul 22, 2020

Description

Migrating gallery/transitions_perf test to e2e, hopefully it can solve the flaky issue for the test.

Related Issues

#30641, #60559, #61458

Tests

This is itself a test

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

@fluttergithubbot fluttergithubbot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Jul 22, 2020
@CareF CareF marked this pull request as draft July 22, 2020 21:00
@CareF CareF self-assigned this Jul 22, 2020
@CareF CareF changed the title Migrate gallery/transitions_perf test to 2e2 Migrate gallery/transitions_perf test to e2e Jul 22, 2020
@CareF
Copy link
Contributor Author

CareF commented Jul 29, 2020

Currently transitions_perf is relying on timeline for the 'Start Transition' event to locate transition:

/// Extracts event data from [events] recorded by timeline, validates it, turns
/// it into a histogram, and saves to a JSON file.
Future<void> saveDurationsHistogram(List<Map<String, dynamic>> events, String outputPath) async {
final Map<String, List<int>> durations = <String, List<int>>{};
Map<String, dynamic> startEvent;
int frameStart;
// Save the duration of the first frame after each 'Start Transition' event.
for (final Map<String, dynamic> event in events) {
final String eventName = event['name'] as String;
if (eventName == 'Start Transition') {

which is defined in the gallery app:
void _launchDemo(BuildContext context) {
if (demo.routeName != null) {
Timeline.instantSync('Start Transition', arguments: <String, String>{
'from': '/',
'to': demo.routeName,
});
Navigator.pushNamed(context, demo.routeName);
}
}

So if we still want to keep avoiding timeline in the solution, we need to modify the app for sending a signal about the transition, or we can just ignore this.
@liyuqian what do you think?


Decided not to track this metric.

@CareF CareF marked this pull request as ready for review July 29, 2020 19:53
@fluttergithubbot fluttergithubbot added the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Jul 29, 2020
@CareF CareF requested a review from liyuqian July 29, 2020 19:53
@CareF
Copy link
Contributor Author

CareF commented Jul 29, 2020

This PR is ready for review. @liyuqian
And I believe this is a very good example of e2e version being able to avoid #59263

@CareF
Copy link
Contributor Author

CareF commented Jul 30, 2020

removed the transition count because I can't decide which frame is the exact frame after transition, due to different epoch in FrameTiming and in DateTime

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! Once this is proved to work, let's add ios and ios32 versions of this in another PR as those are currently flaky.

Copy link
Contributor

Choose a reason for hiding this comment

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

A lot of the following code is very similar to runDemo in https://github.com/flutter/flutter/blob/master/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart.

As we plan to preserve both Flutter driver timeline perf tests and e2e FrameTiming perf tests for a while (partially because timeline still has a lot more information that FrameTiming doesn't), it's probably better to use a single piece of code in both places. Maybe now is a good opportunity to let FlutterDriver implements WidgetController so we can share the code?

This would guarantee that driver tests and e2e tests are measuring similar animations, and avoid the risk that someone changes one test and forget to update another.

Copy link
Contributor Author

@CareF CareF Jul 31, 2020

Choose a reason for hiding this comment

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

It's hard. WidgetController has everything depending on a binding (it can be a test binding or a real binding), but FlutterDriver doesn't have a binding. And the finder in WidgetController and that in FlutterDriver don't share base class.

Copy link
Contributor Author

@CareF CareF Jul 31, 2020

Choose a reason for hiding this comment

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

So to do that, the path in my opinion would be to write a mixin separating the controlling part (not the setting up part) of WidgetController and share this with FlutterDriver, and similarly for both finders. Even with that, there are some APIs doing the same thing but are named differently, meaning the result will be a breaking change. If we still consider abandon flutter_driver for driving the test, I don't think it will be worth it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... your concerns seems to be very legitimate. In that case, for Flutter driver timeline perf tests, can we just control the test inside transitions_perf.dart which is running on device instead of transitions_perf_test.dart? Then it seems that the host side transitions_perf_test.dart only needs to send a signal to device to start the control sequence (and the host will start capturing the timeline tracing events). The device-side code in transitions_perf.dart should be shareable with the E2E test?

Copy link
Contributor Author

@CareF CareF Jul 31, 2020

Choose a reason for hiding this comment

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

Haven't tried but sounds do-able. If that's the case the issue I mentioned above about using WidgetController and thus #62640 becomes necessary, and the measured result may be different with the original flutter_driver ones because it's almost a new test (a host-driven and self-driven hybrid test). Will try after #62640 lands .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3e83f94 is an implementation of making flutter drive test share the driving code with the e2e test (making it a hybrid of host-driven and self-driven).

Copy link
Contributor

Choose a reason for hiding this comment

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

According to our discussion earlier today, it seems that we're not planning to measure transition duration in the e2e test. If so, why do we still do this Firebase specific work as only e2e tests can run on Firebase?

Copy link
Contributor Author

@CareF CareF Jul 31, 2020

Choose a reason for hiding this comment

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

This piece is shared with the original flutter_driver based transition_perf test. I just moved it into an if so in the e2e it doesn't go through this by not providing a transition_duration file name. I don't know why it talks about firebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I didn't realize this code was already there before your PR. It seems to be added by @yjbanov 4 years ago https://github.com/flutter/flutter/blame/30aef0a3b9611763f8e60985e7cca9cb30c1ea6a/dev/devicelab/lib/tasks/gallery.dart#L47.

Yegor: do you still remember why we're doing this as I'm pretty sure we're not using Firebase test lab until very recently? What could happen today if we remove it (the gallery transition test is still not running on Firebase yet)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I now removed this extra work, but I'll wait to see if there's anything breaking that we didn't realize.

@CareF CareF mentioned this pull request Jul 31, 2020
9 tasks
@CareF CareF requested a review from liyuqian July 31, 2020 15:42
@CareF CareF marked this pull request as draft August 5, 2020 15:34
@CareF CareF marked this pull request as ready for review August 7, 2020 01:55
@CareF
Copy link
Contributor Author

CareF commented Aug 7, 2020

@liyuqian Now it's ready for review again. The last commit share the runDemos method between driver test and e2e test, making the former a hybrid test. I'm thinking maybe it is better to create another test case for this and make the previous driver test as is. Though that means there will still be duplicate code.


The commit above (3e83f94) is removed and will be landed in another PR if we decided to use it.

@CareF
Copy link
Contributor Author

CareF commented Aug 10, 2020

@dnfield I removed those duplicate code here, as it's relevant for creating the necessary java code as part of e2e firebase test lab support.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we plan to use this file both in e2e and flutter_driver-timeline tests, maybe we should rename this file?

Copy link
Contributor Author

@CareF CareF Aug 11, 2020

Choose a reason for hiding this comment

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

Nope, this file is not reused as a whole. For the reused version run_demos function will be in a separate file.

@CareF CareF requested a review from liyuqian August 11, 2020 23:40
Copy link
Contributor

@liyuqian liyuqian left a comment

Choose a reason for hiding this comment

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

LGTM

@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite web_tests-1-linux has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot merged commit 2384376 into flutter:master Aug 12, 2020
@CareF CareF deleted the gallery_e2e branch August 12, 2020 20:38
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) c: contributor-productivity Team-specific productivity, code health, technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants