devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Offline data mode causes isFlutterApp to fail with `Null check operator used on a null value`

Open polina-c opened this issue 1 year ago • 7 comments

This code in connected_app.dart fails for connected controllers, when loading saved data:

  Future<bool> get isFlutterApp async => _isFlutterApp ??=
      await serviceManager!.libraryUriAvailable(flutterLibraryUri);

It is expected that connected controller should function as normal in offline data mode.

polina-c avatar May 08 '24 19:05 polina-c

cc @kenzieschmoll

polina-c avatar May 08 '24 19:05 polina-c

Can you provide repro steps? Also, could this have been caused by hot restart robustness issues on web?

kenzieschmoll avatar May 08 '24 19:05 kenzieschmoll

Steps to repro:

  1. Checkout DevTools at ef553c729ca9bd6cabb494fa8551fcd9a0797bb1
  2. Connect to an app
  3. Open memory screen
  4. Open the data: dart_devtools_2024-05-06_17:44:43.187.json
  5. See the error printed in debug console

polina-c avatar May 08 '24 19:05 polina-c

flutter: Null check operator used on a null value
flutter: #0      ConnectedApp.isFlutterApp (package:devtools_app_shared/src/service/connected_app.dart:54:27)
#1      ServiceConnectionManager.rasterCacheMetrics (package:devtools_app/src/service/service_manager.dart:267:35)
#2      MemoryTracker._fetchRasterCacheInfo (package:devtools_app/src/screens/memory/panes/chart/controller/memory_tracker.dart:156:46)
#3      MemoryTracker.pollMemory (package:devtools_app/src/screens/memory/panes/chart/controller/memory_tracker.dart:111:25)
<asynchronous suspension>
#4      ChartVmConnection.init.<anonymous closure> (package:devtools_app/src/screens/memory/panes/chart/controller/chart_connection.dart:81:11)
<asynchronous suspension>
#5      DebounceTimer._runCallback (package:devtools_app/src/shared/utils.dart:264:7)
<asynchronous suspension>

polina-c avatar May 08 '24 19:05 polina-c

Screenshot 2024-05-08 at 12 16 10 PM

polina-c avatar May 08 '24 19:05 polina-c

It also repro on master, but you need to add debug prints before rethrow to see the error.

polina-c avatar May 08 '24 19:05 polina-c

This issue is caused by the fact that we replace the service manager's connected app with the offline connected app. But on the route underneath the current route showing the offline data, the "online" screen still expects the real connected app.

kenzieschmoll avatar May 23 '24 18:05 kenzieschmoll