Repository navigation
Flutter service extensions disabled after a hot-restart #8490
Description
I noticed that if you start a test with a connection to a live app, trigger a hot-restart, and then try to call a service extension from Flutter, the test will fail because the service extension is never re-registered.
I'm pretty sure this is the same underlying cause as #7313, when DWDS was connecting directly to the VM Service URI instead of the DDS URI.
Because DDS intercepts the streamListen request and sends back all of the service extensions it is aware of, these service extensions are never sent back to the DevTools test infra VM service connection.
Here is the code we will likely need to modify (where we get the VM service URI and connect to it):
devtools/packages/devtools_app/test/test_infra/flutter_test_driver.dart
Lines 327 to 358 in 9bd0125
| final debugPort = | |
| await waitFor(event: 'app.debugPort', timeout: appStartTimeout); | |
| final Map<String, dynamic> params = debugPort['params']; | |
| final String wsUriString = params['wsUri']; | |
| _vmServiceWsUri = Uri.parse(wsUriString); | |
| // Map to WS URI. | |
| _vmServiceWsUri = | |
| convertToWebSocketUrl(serviceProtocolUrl: _vmServiceWsUri); | |
| vmService = await vmServiceConnectUriWithFactory<VmServiceWrapper>( | |
| _vmServiceWsUri.toString(), | |
| vmServiceFactory: ({ | |
| // ignore: avoid-dynamic, mirrors types of [VmServiceFactory]. | |
| required Stream<dynamic> /*String|List<int>*/ inStream, | |
| required void Function(String message) writeMessage, | |
| Log? log, | |
| DisposeHandler? disposeHandler, | |
| Future? streamClosed, | |
| String? wsUri, | |
| bool trackFutures = false, | |
| }) => | |
| VmServiceWrapper.defaultFactory( | |
| inStream: inStream, | |
| writeMessage: writeMessage, | |
| log: log, | |
| disposeHandler: disposeHandler, | |
| streamClosed: streamClosed, | |
| wsUri: wsUri, | |
| trackFutures: true, | |
| ), | |
| ); |
@bkonyi Do you happen to know how we could get the DDS URI here instead? Thanks!
Activity
[-]Tests running with a live app looses Flutter service extensions after a hot-restart [/-][+]Tests running with a live app lose Flutter service extensions after a hot-restart [/+]kenzieschmoll commentedon Oct 30, 2024
This may not be just a testing only issue. I noticed that the Performance Overlay button on the performance page becomes disabled after a hot restart, indicating that we are not getting the service extension event registered event after a hot restart is performed.
elliette commentedon Nov 5, 2024
I just saw this too, not while running tests. This seems to be more widespread - we are losing the Flutter service extensions after a hot-restart.
[-]Tests running with a live app lose Flutter service extensions after a hot-restart [/-][+]Flutter service extensions disabled after a hot-restart[/+]elliette commentedon Nov 5, 2024
If I run an app with
--no-dds, the Flutter service extensions are re-registered on hot-restart.bkonyi commentedon Nov 6, 2024
Just to clarify, service extensions registered using
dart:developerdon't actually result inServiceRegisteredevents being sent on theServicestream, butServiceExtensionAddedevents on theIsolatestream.elliette commentedon Nov 6, 2024
I haven't been able to reproduce this anymore. I'm lowering this to P2, but if I encounter it again I will investigate more.
johnpryan commentedon Oct 22, 2026
This has been marked as no longer reproducible and there hasn't been any further activity, closing.