Skip to content

Driver vm service#68654

Merged
dnfield merged 21 commits intoflutter:masterfrom
dnfield:driver_vm_service
Oct 27, 2020
Merged

Driver vm service#68654
dnfield merged 21 commits intoflutter:masterfrom
dnfield:driver_vm_service

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Oct 20, 2020

Migrates package:flutter_driver to use package:vm_service.

This will be needed to eventually completely migrate flutter_driver to null safety. To that end, I've also rewritten the tests to not use mockito.

Part of #37499

Fixes #31813 since package:vm_service is now in charge of that behavior.

@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 Oct 20, 2020
@google-cla google-cla bot added the cla: yes label Oct 20, 2020
@dnfield dnfield added the t: flutter driver "flutter driver", flutter_drive, or a driver test label Oct 20, 2020
group('tap', () {
test('requires a target reference', () async {
expect(driver.tap(null), throwsDriverError);
expect(driver.tap(null), throwsAssertionError);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Several of these changed and I'm not entirely sure why.

I'm not super concerned about it though, since before long we'll be migrating this to NNBD and this test will just go away anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(The test and the entire class of error will change)

url_launcher_linux: 0.0.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
url_launcher_macos: 0.0.1+8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
url_launcher_platform_interface: 1.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
url_launcher_platform_interface: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this version need to be pinned?

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 do not know, @mdebbar or @ditman may know what's going on there. I'm assuming by the time the tree is open again that will be resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

This PR will fix this issue. I'm working now on getting it green so I can land it.

Copy link
Member

Choose a reason for hiding this comment

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

Closing the loop here: Mouad published the fix for the build issue. Apologies for the breakage!

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

This is great

We don't really test drive on presubmit though, the unit tests are trivial. To make sure this can land without being reverted I would validate several devicelab tests locally.

Separately, you may need to investigate google3

@dnfield
Copy link
Contributor Author

dnfield commented Oct 20, 2020

I did run some local driver tests that worked, and a handful of devicelab tests as well.

I need to get this through a FRoB run as well, but posting this is a step towards that.

@jcollins-g
Copy link
Contributor

dartdoc crash tracking at dart-lang/dartdoc#2402

Copy link
Contributor

@bkonyi bkonyi left a comment

Choose a reason for hiding this comment

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

package:vm_service_client is dead! Long live package:vm_service!

Future<vms.Timeline> getVMTimeline({int timeOriginMicros, int timeExtentMicros}) async {
connectionLog.add('getVMTimeline $timeOriginMicros $timeExtentMicros');
final vms.Timeline timeline = timelineResponses[timeOriginMicros ?? 1];
assert(timeline != null, 'Missing entry in timelineResponses[$timeOriginMicros]');
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we run with assertions enabled in tests? If we're not sure, maybe it's safer to just throw here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assertions are enabled for tests, yes.

@dnfield
Copy link
Contributor Author

dnfield commented Oct 21, 2020

I'm still working through testing this internally, requires a few hoops to get vm_service visibility for flutter_driver in the monorepo.

@dnfield
Copy link
Contributor Author

dnfield commented Oct 21, 2020

Internal runs are failing because of unrelated changes related to NNBD. I'll wait until that's cleaned up internally and try to re-run the tests.

@jcollins-g
Copy link
Contributor

dartdoc crash tracking at dart-lang/dartdoc#2402

#68791 will fix this for Flutter.

}

return isolate.resume().catchError((dynamic e) {
return await client.resume(isolate.id).catchError((dynamic e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

return await is pointless

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

'Attempted to resume an already resumed isolate. This may happen '
'when we lose a race with another tool (usually a debugger) that '
'is connected to the same isolate.'
'when we lose a race with another tool (usually a debugger) that '
Copy link
Contributor

Choose a reason for hiding this comment

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

nit while you are here: no "we"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

.loadRunnable()
.then((VMIsolate isolate) async {
if (isolate.extensionRpcs.contains(_flutterExtensionMethodName)) {
await client.streamListen(vms.EventStreams.kIsolate);
Copy link
Contributor

Choose a reason for hiding this comment

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

this will throw an exception if the stream has already been subscribed to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would be unexpected, since we unsubscribe at the end of this method.

.sendRequest(_collectAllGarbageMethodName, <String, String>{
'isolateId': 'isolates/${_appIsolate.numberAsString}',
});
await _serviceClient.callMethod(_collectAllGarbageMethodName, isolateId: _appIsolate.id);
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this method is deprecated and no longer does anything

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're "not supposed" to use it, but it does work. It's not guaranteed to do anything but it normally works well enough.

We can't remove this - it's used in many of our benchmarks to reduce flakiness.

@dnfield
Copy link
Contributor Author

dnfield commented Oct 23, 2020

This will be blocked until a resolution to dart-lang/sdk#43898 is rolled into google.

@dnfield
Copy link
Contributor Author

dnfield commented Oct 23, 2020

This patch is now passing internally, with some additional updates at cl/338576267 to cover new dependency changes and some internal usages of API that isn't available anymore (specifically, not using the vm_service_client API that we used to expose through this lib).

@dnfield
Copy link
Contributor Author

dnfield commented Oct 23, 2020

@renyou -why doesn't FROB let me apply a G3Fix to this PR? It's approved by bkonyi.


/// Workaround for isolates being paused by driver tests.
/// https://github.com/flutter/flutter/issues/24703
class IsolatesWorkaround {
Copy link
Contributor

Choose a reason for hiding this comment

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

\o/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was actually fixed by a different patch, but became apparent in this one because it's trying to use API the driver no longer exposes :)

/// The `fuchsiaModuleTarget` parameter specifies the pattern for determining
/// which mod to control. When running on a Fuchsia device, either this or the
/// environment variable `FUCHSIA_MODULE_TARGET` must be set (the environment
/// variable is treated as a substring pattern). This field will be ignored if
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also say that this parameter is ignored on non-Fuchsia devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

/// `browser` specifies which FlutterDriver implementation to use. If not
/// speicifed or set to false, [VMServiceFlutterDriver] implementation
/// will be used. Otherwise, [WebFlutterDriver] implementation will be used.
/// The `browser` parameter specifies which FlutterDriver implementation to
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm failing to find the browser parameter this part is talking about 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like someone removed that and forgot to remove the docs. Removing this block.

isolate.pauseEvent is! VMPauseInterruptedEvent &&
isolate.pauseEvent is! VMResumeEvent) {
isolate = await isolateRef.loadRunnable();
if (isolate.pauseEvent.kind == vms.EventKind.kNone) {
Copy link
Contributor

Choose a reason for hiding this comment

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

\o/

@dnfield
Copy link
Contributor Author

dnfield commented Oct 26, 2020

Note to self or anyone else looking at this due to a devicelab failure:

I did not run all devicelab tests. We should feel free to aggressively revert this if it's causing devicelab failures. That said, if we need to revert we should ideally do so before it rolls into google3, as that will complicate reverts.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM ship it

@dnfield dnfield merged commit 3ecac30 into flutter:master Oct 27, 2020
@dnfield
Copy link
Contributor Author

dnfield commented Oct 27, 2020

All tests that CI should be able to catch are passing - will watch devicelab.

dnfield added a commit that referenced this pull request Oct 27, 2020
jonahwilliams pushed a commit that referenced this pull request Oct 27, 2020
This reverts commit 3ecac30.

Co-authored-by: Dan Field <[email protected]>
dnfield added a commit that referenced this pull request Oct 27, 2020
dnfield added a commit that referenced this pull request Oct 27, 2020
dnfield added a commit that referenced this pull request Oct 27, 2020
dnfield added a commit that referenced this pull request Oct 27, 2020
dnfield added a commit to dnfield/flutter that referenced this pull request Oct 27, 2020
dnfield added a commit that referenced this pull request Oct 27, 2020
* One more reland of "Driver vm service (#68654)" (#69074)" (#69077)" (#69089)"

This reverts commit e581475.

* pub run test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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. t: flutter driver "flutter driver", flutter_drive, or a driver test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No such method: streamNotify

7 participants