Fix performance when JSON is invalid (#10005) * Fixes https://github.com/flutter/devtools/issues/4172 1. **Fixed performance_model.dart:68-71**: * Updated isEmpty to verify that there is no trace binary, no frames, and no rebuild model. 2. **Guarded Perfetto trace loading in timeline_events_controller.dart:501-506**: * Avoided attempting to process track events or load a trace into Perfetto when perfettoTraceBinary is null or empty, allowing offline Flutter frames to display cleanly. 3. **Added validation in import_export.dart:72-106**: * Added null-safety check for activeScreenId with user-facing notification if missing from the snapshot. * Added a check verifying that the JSON contains data for activeScreenId (json.containsKey(activeScreenId) && json[activeScreenId] != null), preventing navigation to a broken snapshot screen and immediately notifying the user. 4. **Added error handling and notifications in offline_data.dart:173-200**: * Pushes a notification if the file data for that screen is empty (!shouldLoad(screenData)). * Wraps deserialization and loading in a try / catch block to log and display an error message if parsing fails. 5. Tests & Release Notes: * Added tests in import_export_test.dart for missing activeScreenId and missing screen data. * Added unit tests in performance_model_test.dart for OfflinePerformanceData.isEmpty. * Created offline_data_test.dart testing OfflineScreenControllerMixin loading, empty payload notifications, and error handling. * Documented the changes in NEXT_RELEASE_NOTES.md. * feedback * feedback
Dart & Flutter DevTools is a suite of performance tools for Dart and Flutter.
For documentation on installing and trying out DevTools, please see our docs.
Contributions welcome! See our contributing page for an overview of how to build and contribute to the project.
By using Dart DevTools, you agree to the Google Terms of Service. To understand how we use data collected from this service, see the Google Privacy Policy.