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

[DDS] Add support for setting initial service extension values from DDS #44611

Open
kenzieschmoll opened this issue Jan 7, 2021 · 4 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. pkg-dds For issues related to the Dart Development Service

Comments

@kenzieschmoll
Copy link
Contributor

A service extension may need to be called before an app starts up. From a tooling perspective, this is often to set an initial value for a service extension. For example, in DevTools currently, we have to queue these calls as pending, wait until the Flutter.FirstFrame event is received, and then issue all outstanding calls to service extensions.

It would be ideal if DDS act as an intermediate layer to handle this use case. DDS could receive these calls, then manage executing the calls immediately on startup. This would avoid the problem of managing the race across tools. I am working on a feature in flutter tools currently that likely will also run into this race issue, where I need to set the value of a service extension but will have to make sure the device has started up.

@bkonyi @jacob314

@kenzieschmoll kenzieschmoll added the pkg-dds For issues related to the Dart Development Service label Jan 7, 2021
@jacob314
Copy link
Member

jacob314 commented Jan 7, 2021

We can't just use dart environment variables to handle these cases because environment variables aren't supported on all Dart platforms we need to support.
It could be that changes to support this need to be partly in the VM Service itself. A reasonable division might be that the VMService allows accepting payload to immediately call a service extension with on isolate start and DDS supports persisting setting values for service extensions across isolates.

Another component of this FR could be codifying the flutter concept of boolean and string value service extensions that act like getter setter pairs in dart:developer.

@vsmenon vsmenon added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Jan 8, 2021
@bkonyi
Copy link
Contributor

bkonyi commented Mar 24, 2021

I'm not sure I'm clear on how we can issue service requests before the application starts up and starts advertising its VM service URI. DDS won't be started in any context until a VM service is available. Am I missing something here?

@bkonyi
Copy link
Contributor

bkonyi commented Apr 6, 2022

Going through my backlog. Is this issue still relevant?

@jacob314
Copy link
Member

jacob314 commented Apr 7, 2022

This is still relevant. Flutter has adopted some good conventions for service extensions that get and set values that that should be promoted to dart:developer and the VMService rather than as just a convention in the Flutter code base. With those conventions, the semantics for setting values immediately on VM startup become clean.

See registerBoolServiceExtension, registerStringServiceExtension, registerNumericServiceExtension, registerNumericServiceExtension for the existing Flutter apis.
https://github.com/flutter/flutter/blob/852bfe2a73e2ca059c1a0031879101231b946f5f/packages/flutter/lib/src/foundation/binding.dart#L652
The functionality for these APIs would be refined slightly to support immediately invoking the setter if a default value has been set before the service extension was registered. Only the very last default value set needs to be applied in case multiple VMService clients set a value. Getters cannot be called before service extensions are registered.

I think it would make sense to add helpers with exactly this bool, String, and num service extension behavior to dart:developer. Setters could be called on VM startup with the last value set applied as soon as the service extension is registered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. pkg-dds For issues related to the Dart Development Service
Projects
None yet
Development

No branches or pull requests

4 participants