Use the new getIsolatePauseEvent
method from VM service to check for pause event. (#128834)
The `getIsolate` method returns the full list of libraries which can be huge for large apps. Using the more speficic API to only fetch what we need improves hot reload performance. *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This commit is contained in:
parent
80935ad984
commit
3291750082
@ -1298,9 +1298,8 @@ Future<ReassembleResult> _defaultReassembleHelper(
|
||||
for (final FlutterView view in views) {
|
||||
// Check if the isolate is paused, and if so, don't reassemble. Ignore the
|
||||
// PostPauseEvent event - the client requesting the pause will resume the app.
|
||||
final vm_service.Isolate? isolate = await device!.vmService!
|
||||
.getIsolateOrNull(view.uiIsolate!.id!);
|
||||
final vm_service.Event? pauseEvent = isolate?.pauseEvent;
|
||||
final vm_service.Event? pauseEvent = await device!.vmService!
|
||||
.getIsolatePauseEventOrNull(view.uiIsolate!.id!);
|
||||
if (pauseEvent != null
|
||||
&& isPauseEvent(pauseEvent.kind!)
|
||||
&& pauseEvent.kind != vm_service.EventKind.kPausePostRequest) {
|
||||
@ -1364,16 +1363,13 @@ Future<ReassembleResult> _defaultReassembleHelper(
|
||||
int postReloadPausedIsolatesFound = 0;
|
||||
String? serviceEventKind;
|
||||
for (final FlutterView view in reassembleViews.keys) {
|
||||
final vm_service.Isolate? isolate = await reassembleViews[view]!
|
||||
.getIsolateOrNull(view.uiIsolate!.id!);
|
||||
if (isolate == null) {
|
||||
continue;
|
||||
}
|
||||
if (isolate.pauseEvent != null && isPauseEvent(isolate.pauseEvent!.kind!)) {
|
||||
final vm_service.Event? pauseEvent = await reassembleViews[view]!
|
||||
.getIsolatePauseEventOrNull(view.uiIsolate!.id!);
|
||||
if (pauseEvent != null && isPauseEvent(pauseEvent.kind!)) {
|
||||
postReloadPausedIsolatesFound += 1;
|
||||
if (serviceEventKind == null) {
|
||||
serviceEventKind = isolate.pauseEvent!.kind;
|
||||
} else if (serviceEventKind != isolate.pauseEvent!.kind) {
|
||||
serviceEventKind = pauseEvent.kind;
|
||||
} else if (serviceEventKind != pauseEvent.kind) {
|
||||
serviceEventKind = ''; // many kinds
|
||||
}
|
||||
}
|
||||
|
@ -1110,6 +1110,22 @@ class FlutterVmService {
|
||||
});
|
||||
}
|
||||
|
||||
/// Attempt to retrieve the isolate pause event with id [isolateId], or `null` if it has
|
||||
/// been collected.
|
||||
Future<vm_service.Event?> getIsolatePauseEventOrNull(String isolateId) async {
|
||||
return service.getIsolatePauseEvent(isolateId)
|
||||
.then<vm_service.Event?>(
|
||||
(vm_service.Event event) => event,
|
||||
onError: (Object? error, StackTrace stackTrace) {
|
||||
if (error is vm_service.SentinelException ||
|
||||
error == null ||
|
||||
(error is vm_service.RPCError && error.code == RPCErrorCodes.kServiceDisappeared)) {
|
||||
return null;
|
||||
}
|
||||
return Future<vm_service.Event?>.error(error, stackTrace);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a new development file system on the device.
|
||||
Future<vm_service.Response> createDevFS(String fsName) {
|
||||
// Call the unchecked version of `callServiceExtension` because the caller
|
||||
|
@ -45,12 +45,19 @@ import '../src/fake_vm_services.dart';
|
||||
import '../src/fakes.dart';
|
||||
import '../src/testbed.dart';
|
||||
|
||||
final vm_service.Event fakeUnpausedEvent = vm_service.Event(
|
||||
kind: vm_service.EventKind.kResume,
|
||||
timestamp: 0
|
||||
);
|
||||
|
||||
final vm_service.Event fakePausedEvent = vm_service.Event(
|
||||
kind: vm_service.EventKind.kPauseException,
|
||||
timestamp: 0
|
||||
);
|
||||
|
||||
final vm_service.Isolate fakeUnpausedIsolate = vm_service.Isolate(
|
||||
id: '1',
|
||||
pauseEvent: vm_service.Event(
|
||||
kind: vm_service.EventKind.kResume,
|
||||
timestamp: 0
|
||||
),
|
||||
pauseEvent: fakeUnpausedEvent,
|
||||
breakpoints: <vm_service.Breakpoint>[],
|
||||
extensionRPCs: <String>[],
|
||||
libraries: <vm_service.LibraryRef>[
|
||||
@ -72,10 +79,7 @@ final vm_service.Isolate fakeUnpausedIsolate = vm_service.Isolate(
|
||||
|
||||
final vm_service.Isolate fakePausedIsolate = vm_service.Isolate(
|
||||
id: '1',
|
||||
pauseEvent: vm_service.Event(
|
||||
kind: vm_service.EventKind.kPauseException,
|
||||
timestamp: 0
|
||||
),
|
||||
pauseEvent: fakePausedEvent,
|
||||
breakpoints: <vm_service.Breakpoint>[
|
||||
vm_service.Breakpoint(
|
||||
breakpointNumber: 123,
|
||||
@ -537,11 +541,11 @@ void main() {
|
||||
listViews,
|
||||
listViews,
|
||||
FakeVmServiceRequest(
|
||||
method: 'getIsolate',
|
||||
method: 'getIsolatePauseEvent',
|
||||
args: <String, Object>{
|
||||
'isolateId': '1',
|
||||
},
|
||||
jsonResponse: fakeUnpausedIsolate.toJson(),
|
||||
jsonResponse: fakeUnpausedEvent.toJson(),
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'ext.flutter.reassemble',
|
||||
@ -604,11 +608,11 @@ void main() {
|
||||
},
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'getIsolate',
|
||||
method: 'getIsolatePauseEvent',
|
||||
args: <String, Object>{
|
||||
'isolateId': '1',
|
||||
},
|
||||
jsonResponse: fakeUnpausedIsolate.toJson(),
|
||||
jsonResponse: fakeUnpausedEvent.toJson(),
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'ext.flutter.reassemble',
|
||||
@ -728,11 +732,11 @@ void main() {
|
||||
},
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'getIsolate',
|
||||
method: 'getIsolatePauseEvent',
|
||||
args: <String, Object>{
|
||||
'isolateId': '1',
|
||||
},
|
||||
jsonResponse: fakeUnpausedIsolate.toJson(),
|
||||
jsonResponse: fakeUnpausedEvent.toJson(),
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'ext.flutter.reassemble',
|
||||
@ -791,11 +795,11 @@ void main() {
|
||||
},
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'getIsolate',
|
||||
method: 'getIsolatePauseEvent',
|
||||
args: <String, Object>{
|
||||
'isolateId': '1',
|
||||
},
|
||||
jsonResponse: fakeUnpausedIsolate.toJson(),
|
||||
jsonResponse: fakeUnpausedEvent.toJson(),
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'ext.flutter.fastReassemble',
|
||||
@ -882,11 +886,11 @@ void main() {
|
||||
},
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'getIsolate',
|
||||
method: 'getIsolatePauseEvent',
|
||||
args: <String, Object>{
|
||||
'isolateId': '1',
|
||||
},
|
||||
jsonResponse: fakeUnpausedIsolate.toJson(),
|
||||
jsonResponse: fakeUnpausedEvent.toJson(),
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'ext.flutter.fastReassemble',
|
||||
|
Loading…
x
Reference in New Issue
Block a user