Skip to content

Conversation

@speaking-in-code
Copy link
Contributor

Description

Fixes #24703.

Flutter driver has problems when flutter apps use more than a single isolate. The other isolates don't start, so apps malfunction. This PR fixes the problem by listening for new isolates to become runnable, and automatically starting them.

Related Issues

#24703.

Tests

I added the following tests:

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.
  • [x ] I signed the [CLA].
  • [x ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • [x ] I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • [x ] I updated/added relevant documentation (doc comments with ///).
  • [x ] All existing and new tests are passing.
  • [x ] The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • [x ] 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.
  • Yes, this is a breaking change.

@flutter-dashboard flutter-dashboard bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Aug 7, 2020
@guidezpl guidezpl changed the title Make sure all isolates start during flutter driver tests. Reland "Make sure all isolates start during flutter driver tests" Aug 7, 2020
Copy link
Member

@guidezpl guidezpl left a comment

Choose a reason for hiding this comment

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

  _    ___ _____ __  __ 
 | |  / __|_   _|  \/  |
 | |_| (_ | | | | |\/| |
 |____\___| |_| |_|  |_|
                        

@goderbauer
Copy link
Member

PR triage: @guidezpl @speaking-in-code Is this ready to be submitted? Or still waiting on anything?

@speaking-in-code
Copy link
Contributor Author

"Google testing" is the last pending check. Not sure how long that normally takes, but it's been a few days now.

Other than that, AFAIK, this is good for submission now.

@guidezpl
Copy link
Member

Good to merge after Google testing gets unstuck.

@renyou I was unable to manually test this PR on go/flutter-rob. Could you have a look?

@speaking-in-code
Copy link
Contributor Author

Anything I can do to get the Google testing unstuck?

@guidezpl
Copy link
Member

There were some genuine failed internal tests, I'll do some more digging this week to figure out the root cause

@guidezpl
Copy link
Member

guidezpl commented Aug 20, 2020

Alright, after doing some digging, it seems the bug still exists. I found two issues while using the repro case from the original issue.

  1. flutter drive targeting a mobile device (I used a physical Android device) finds the isolate to be paused, and resumes it both with and without this PR with identical logs and failure.
VMServiceFlutterDriver: Isolate found with number: 2890840248319923
VMServiceFlutterDriver: Isolate is paused at start.
VMServiceFlutterDriver: Attempting to resume isolate
VMServiceFlutterDriver: Connected to Flutter application.
00:02 +0: Counter App starts at 0

00:02 +1: Counter App increments the counter

00:02 +1 -1: Counter App increments the counter [E]

  Expected: '1'
    Actual: '0'
     Which: is different.
            Expected: 1
              Actual: 0
                      ^
             Differ at offset 0
...

I think this is because the isolate spawned by final s = await compute(_test, 'hello'); never actually gets resumed and the following setState statement to increment the counter never gets executed.

  1. flutter drive targeting macOS finds the isolate not to be paused. It currently runs correctly
VMServiceFlutterDriver: Isolate found with number: 3416477323685147
VMServiceFlutterDriver: Isolate is not paused. Assuming application is ready.
VMServiceFlutterDriver: Connected to Flutter application.
...
All tests passed

But with this PR, the additional attempt to resume fails hard, since the error is a StateError and not anrpc.RpcException.

VMServiceFlutterDriver: Isolate found with number: 3416477323685147
VMServiceFlutterDriver: Isolate is not paused. Assuming application is ready.
VMServiceFlutterDriver: Connected to Flutter application.
VMServiceFlutterDriver: Attempting to resume isolate
...
Original error: Bad state: The client closed with pending request "ext.flutter.driver".
...

If you'd like to continue work to try and find a solution to these, I encourage you to test against the original repro case. Testing against the gallery was a mistake on my part; Please don't hesitate to reach out to past contributors, who have much more knowledge about the driver than I do.

@speaking-in-code
Copy link
Contributor Author

thanks @guidezpl. will try this out on more test cases to see if I can repro what you're seeing.

@speaking-in-code
Copy link
Contributor Author

I've added an integration test for isolates to the flutter examples directory. Not sure if that's the right place for it, but having it around is useful.

The issues you found were fixed as follows:

  1. The original Counter App + compute() integration test was brittle. It would not pass if there were async updates to the screen. That was fixed by making the test more robust.

  2. MacOS threw a bit of a fit when trying to resume an unpaused isolate. The fix was not to do that.

One oddness I've encountered is isolate.pauseEvent being set to VMNoneEvent. That happens when I'm using the audio_service library, which is starting isolates from a flutter plugin on iOS and Android. I haven't been able to reproduce that with a simpler test case, so there's no integration test for that yet. If you have simple ideas for how to reproduce VMNoneEvent, let me know, I can try to add that test case as well.

I can see that the analyze-linux step has failed due to my changes. I'll clean that up tomorrow.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests c: contributor-productivity Team-specific productivity, code health, technical debt. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter_driver pauses all isolates at their startup (even ones started from compute()), rather than only pausing initial isolate

4 participants