-
Notifications
You must be signed in to change notification settings - Fork 403
Fix performance when JSON is invalid #10005
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import 'dart:async'; | |
| import 'package:devtools_app_shared/service.dart'; | ||
| import 'package:devtools_app_shared/utils.dart'; | ||
| import 'package:flutter/foundation.dart'; | ||
| import 'package:logging/logging.dart'; | ||
|
|
||
| import '../config_specific/import_export/import_export.dart'; | ||
| import '../framework/routing.dart'; | ||
|
|
@@ -131,6 +132,8 @@ class OfflineDataController { | |
| /// ), | ||
| /// } | ||
| /// ``` | ||
| final _log = Logger('offline_data'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the above dartdoc goes with |
||
|
|
||
| mixin OfflineScreenControllerMixin<T> | ||
| on DevToolsScreenController, AutoDisposeControllerMixin { | ||
| final _exportController = ExportController(); | ||
|
|
@@ -168,19 +171,41 @@ mixin OfflineScreenControllerMixin<T> | |
| required FutureOr<void> Function(T data) loadData, | ||
| }) async { | ||
| if (offlineDataController.shouldLoadOfflineData(screenId)) { | ||
| // TODO(kenz): investigate this line of code. Do we need to be creating a | ||
| // second copy of the Map from offlineDataController.offlineDataJson or | ||
| // can we use it directly to save this `Map.of` call? | ||
| final json = Map<String, Object?>.of( | ||
| (offlineDataController.offlineDataJson[screenId] as Map) | ||
| .cast<String, Object?>(), | ||
| ); | ||
| final screenData = createData(json); | ||
| final T screenData; | ||
| try { | ||
| // TODO(kenz): investigate this line of code. Do we need to be creating a | ||
| // second copy of the Map from offlineDataController.offlineDataJson or | ||
| // can we use it directly to save this `Map.of` call? | ||
| final json = Map<String, Object?>.of( | ||
| (offlineDataController.offlineDataJson[screenId] as Map) | ||
| .cast<String, Object?>(), | ||
| ); | ||
| screenData = createData(json); | ||
| } catch (e, st) { | ||
| _log.shout('Error parsing offline data for $screenId', e, st); | ||
| notificationService.push( | ||
| 'Failed to load offline data for screen \'$screenId\': $e', | ||
| ); | ||
| return false; | ||
| } | ||
|
|
||
| if (shouldLoad(screenData)) { | ||
| _loadingOfflineData.value = true; | ||
| await loadData(screenData); | ||
| _loadingOfflineData.value = false; | ||
| return true; | ||
| try { | ||
| await loadData(screenData); | ||
| return true; | ||
| } catch (e, st) { | ||
| _log.shout('Error loading offline data for $screenId', e, st); | ||
| notificationService.push( | ||
| 'Failed to load offline data for screen \'$screenId\': $e', | ||
| ); | ||
| } finally { | ||
| _loadingOfflineData.value = false; | ||
| } | ||
| } else { | ||
| notificationService.push( | ||
| 'The imported file does not contain any data for screen \'$screenId\'.', | ||
|
Comment on lines
+206
to
+207
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if shouldLoad is true, does this always mean that the data was empty? can a screen return false for some other reason than the data being empty? |
||
| ); | ||
| } | ||
| } | ||
| return false; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,14 +18,19 @@ To learn more about DevTools, check out the | |
| * Fixed unreadable text in the release notes panel, where blockquotes were | ||
| drawn on a hard coded light blue background in the dark theme. | ||
| [#9957](https://github.com/flutter/devtools/pull/9957) | ||
| * Added user-facing error notifications when importing data files that are | ||
| missing required fields or contain no data for the screen. | ||
| [TODO](https://github.com/flutter/devtools/pull/TODO) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update this link and the one below |
||
|
|
||
| ## Inspector updates | ||
|
|
||
| TODO: Remove this section if there are not any updates. | ||
|
|
||
| ## Performance updates | ||
|
|
||
| TODO: Remove this section if there are not any updates. | ||
| * Fixed an issue where importing performance data with Flutter frames but no | ||
| timeline trace would treat the data as empty. | ||
| [TODO](https://github.com/flutter/devtools/pull/TODO) | ||
|
|
||
| ## CPU profiler updates | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can avoid two null assertions by putting this in a var.