Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check for debugDidSendFirstFrameEvent when adding service extensions for Dart VM apps. #1670

Merged
merged 2 commits into from
Feb 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions packages/devtools_app/lib/src/service_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class ServiceConnectionManager {
serviceAvailable.complete();

connectedApp = ConnectedApp();
serviceExtensionManager.connectedApp = connectedApp;

unawaited(onClosed.then((_) => vmServiceClosed()));

Expand Down Expand Up @@ -205,6 +206,7 @@ class ServiceConnectionManager {
vm = null;
sdkVersion = null;
connectedApp = null;
serviceExtensionManager.connectedApp = null;

_stateController.add(false);
_connectionClosedController.add(null);
Expand Down Expand Up @@ -446,6 +448,8 @@ class ServiceExtensionManager {

var extensionStatesUpdated = Completer<void>();

ConnectedApp connectedApp;

Future<void> _handleExtensionEvent(Event event) async {
switch (event.extensionKind) {
case 'Flutter.FirstFrame':
Expand Down Expand Up @@ -513,42 +517,46 @@ class ServiceExtensionManager {
}
final Isolate isolate = await _service.getIsolate(isolateRef.id);
if (isolate.extensionRPCs != null) {
for (String extension in isolate.extensionRPCs) {
await _maybeAddServiceExtension(extension);
}
if (await connectedApp.isAnyFlutterApp) {
for (String extension in isolate.extensionRPCs) {
await _maybeAddServiceExtension(extension);
}

if (_pendingServiceExtensions.isEmpty) {
extensionStatesUpdated.complete();
}
if (_pendingServiceExtensions.isEmpty) {
extensionStatesUpdated.complete();
}

if (!_firstFrameEventReceived) {
bool didSendFirstFrameEvent = false;
if (isServiceExtensionAvailable(extensions.didSendFirstFrameEvent)) {
final value = await _service.callServiceExtension(
extensions.didSendFirstFrameEvent,
isolateId: _isolateManager.selectedIsolate.id,
);
didSendFirstFrameEvent =
value != null && value.json['enabled'] == 'true';
} else {
final EvalOnDartLibrary flutterLibrary = EvalOnDartLibrary(
[
'package:flutter/src/widgets/binding.dart',
'package:flutter_web/src/widgets/binding.dart',
],
_service,
);
final InstanceRef value = await flutterLibrary.eval(
'WidgetsBinding.instance.debugDidSendFirstFrameEvent',
isAlive: null,
);
if (!_firstFrameEventReceived) {
bool didSendFirstFrameEvent = false;
if (isServiceExtensionAvailable(extensions.didSendFirstFrameEvent)) {
final value = await _service.callServiceExtension(
extensions.didSendFirstFrameEvent,
isolateId: _isolateManager.selectedIsolate.id,
);
didSendFirstFrameEvent = value?.json['enabled'] == 'true';
} else {
final EvalOnDartLibrary flutterLibrary = EvalOnDartLibrary(
[
'package:flutter/src/widgets/binding.dart',
],
_service,
);
final InstanceRef value = await flutterLibrary.eval(
'WidgetsBinding.instance.debugDidSendFirstFrameEvent',
isAlive: null,
);

didSendFirstFrameEvent =
value != null && value.valueAsString == 'true';
}

didSendFirstFrameEvent =
value != null && value.valueAsString == 'true';
if (didSendFirstFrameEvent) {
await _onFrameEventReceived();
}
}

if (didSendFirstFrameEvent) {
await _onFrameEventReceived();
} else {
for (String extension in isolate.extensionRPCs) {
await _addServiceExtension(extension);
}
}
Comment on lines +557 to 561
Copy link
Member Author

Choose a reason for hiding this comment

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

@jacob314 we are adding service extensions for non flutter apps here

}
Expand Down