leak tracking setup

This commit is contained in:
Thibault Deckers 2024-10-26 00:58:52 +02:00
parent 8de8d26756
commit 3a63533dd9
15 changed files with 45 additions and 30 deletions

View file

@ -13,6 +13,7 @@ import 'package:aves/utils/time_utils.dart';
import 'package:aves_model/aves_model.dart'; import 'package:aves_model/aves_model.dart';
import 'package:aves_utils/aves_utils.dart'; import 'package:aves_utils/aves_utils.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:leak_tracker/leak_tracker.dart';
enum EntryDataType { basic, aspectRatio, catalog, address, references } enum EntryDataType { basic, aspectRatio, catalog, address, references }
@ -72,7 +73,7 @@ class AvesEntry with AvesEntryBase {
this.stackedEntries, this.stackedEntries,
}) : id = id ?? 0 { }) : id = id ?? 0 {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$AvesEntry', className: '$AvesEntry',
object: this, object: this,
@ -188,7 +189,7 @@ class AvesEntry with AvesEntryBase {
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
visualChangeNotifier.dispose(); visualChangeNotifier.dispose();
metadataChangeNotifier.dispose(); metadataChangeNotifier.dispose();

View file

@ -4,6 +4,7 @@ import 'package:aves/ref/mime_types.dart';
import 'package:aves/services/common/services.dart'; import 'package:aves/services/common/services.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:leak_tracker/leak_tracker.dart';
class MultiPageInfo { class MultiPageInfo {
final AvesEntry mainEntry; final AvesEntry mainEntry;
@ -18,7 +19,7 @@ class MultiPageInfo {
required List<SinglePageInfo> pages, required List<SinglePageInfo> pages,
}) : _pages = pages { }) : _pages = pages {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$MultiPageInfo', className: '$MultiPageInfo',
object: this, object: this,
@ -44,7 +45,7 @@ class MultiPageInfo {
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
_transientEntries.forEach((entry) => entry.dispose()); _transientEntries.forEach((entry) => entry.dispose());
} }

View file

@ -1,4 +1,5 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:leak_tracker/leak_tracker.dart';
class AnalysisController { class AnalysisController {
final bool canStartService, force; final bool canStartService, force;
@ -15,7 +16,7 @@ class AnalysisController {
this.progressOffset = 0, this.progressOffset = 0,
}) { }) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$AnalysisController', className: '$AnalysisController',
object: this, object: this,
@ -25,7 +26,7 @@ class AnalysisController {
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
_stopSignal.dispose(); _stopSignal.dispose();
} }

View file

@ -30,6 +30,7 @@ import 'package:aves_model/aves_model.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:event_bus/event_bus.dart'; import 'package:event_bus/event_bus.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:leak_tracker/leak_tracker.dart';
enum SourceScope { none, album, full } enum SourceScope { none, album, full }
@ -64,7 +65,7 @@ mixin SourceBase {
abstract class CollectionSource with SourceBase, AlbumMixin, CountryMixin, PlaceMixin, StateMixin, LocationMixin, TagMixin, TrashMixin { abstract class CollectionSource with SourceBase, AlbumMixin, CountryMixin, PlaceMixin, StateMixin, LocationMixin, TagMixin, TrashMixin {
CollectionSource() { CollectionSource() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$CollectionSource', className: '$CollectionSource',
object: this, object: this,
@ -88,7 +89,7 @@ abstract class CollectionSource with SourceBase, AlbumMixin, CountryMixin, Place
@mustCallSuper @mustCallSuper
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
_rawEntries.forEach((v) => v.dispose()); _rawEntries.forEach((v) => v.dispose());
} }

View file

@ -13,6 +13,7 @@ import 'package:aves_model/aves_model.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:leak_tracker/leak_tracker.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
class AnalysisService { class AnalysisService {
@ -99,7 +100,7 @@ class Analyzer with WidgetsBindingObserver {
Analyzer() { Analyzer() {
debugPrint('$runtimeType create'); debugPrint('$runtimeType create');
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$Analyzer', className: '$Analyzer',
object: this, object: this,
@ -113,7 +114,7 @@ class Analyzer with WidgetsBindingObserver {
void dispose() { void dispose() {
debugPrint('$runtimeType dispose'); debugPrint('$runtimeType dispose');
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
_stopUpdateTimer(); _stopUpdateTimer();
_controller?.dispose(); _controller?.dispose();

View file

@ -5,6 +5,7 @@ import 'package:aves/widgets/common/search/route.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:leak_tracker/leak_tracker.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
abstract class AvesSearchDelegate extends SearchDelegate { abstract class AvesSearchDelegate extends SearchDelegate {
@ -21,7 +22,7 @@ abstract class AvesSearchDelegate extends SearchDelegate {
required super.searchFieldStyle, required super.searchFieldStyle,
}) { }) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$AvesSearchDelegate', className: '$AvesSearchDelegate',
object: this, object: this,
@ -137,7 +138,7 @@ abstract class AvesSearchDelegate extends SearchDelegate {
@mustCallSuper @mustCallSuper
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
currentBodyNotifier.dispose(); currentBodyNotifier.dispose();
queryTextController.dispose(); queryTextController.dispose();

View file

@ -5,6 +5,7 @@ import 'package:aves/model/settings/settings.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:leak_tracker/leak_tracker.dart';
class TileExtentController { class TileExtentController {
final String settingsRouteKey; final String settingsRouteKey;
@ -28,7 +29,7 @@ class TileExtentController {
required this.horizontalPadding, required this.horizontalPadding,
}) { }) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$TileExtentController', className: '$TileExtentController',
object: this, object: this,
@ -42,7 +43,7 @@ class TileExtentController {
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
_subscriptions _subscriptions
..forEach((sub) => sub.cancel()) ..forEach((sub) => sub.cancel())

View file

@ -5,6 +5,7 @@ import 'package:aves/widgets/editor/transform/crop_region.dart';
import 'package:aves/widgets/editor/transform/transformation.dart'; import 'package:aves/widgets/editor/transform/transformation.dart';
import 'package:aves_model/aves_model.dart'; import 'package:aves_model/aves_model.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:leak_tracker/leak_tracker.dart';
class TransformController { class TransformController {
ValueNotifier<CropAspectRatio> aspectRatioNotifier = ValueNotifier(CropAspectRatio.free); ValueNotifier<CropAspectRatio> aspectRatioNotifier = ValueNotifier(CropAspectRatio.free);
@ -34,7 +35,7 @@ class TransformController {
TransformController(this.displaySize) { TransformController(this.displaySize) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$TransformController', className: '$TransformController',
object: this, object: this,
@ -46,7 +47,7 @@ class TransformController {
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
aspectRatioNotifier.dispose(); aspectRatioNotifier.dispose();
} }

View file

@ -25,6 +25,7 @@ import 'package:aves_video/aves_video.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:leak_tracker/leak_tracker.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class VideoActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMixin { class VideoActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMixin {
@ -35,7 +36,7 @@ class VideoActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMix
required this.collection, required this.collection,
}) { }) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$VideoActionDelegate', className: '$VideoActionDelegate',
object: this, object: this,
@ -45,7 +46,7 @@ class VideoActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMix
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
stopOverlayHidingTimer(); stopOverlayHidingTimer();
} }

View file

@ -10,6 +10,7 @@ import 'package:aves_magnifier/aves_magnifier.dart';
import 'package:aves_model/aves_model.dart'; import 'package:aves_model/aves_model.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:leak_tracker/leak_tracker.dart';
class ViewerController with CastMixin { class ViewerController with CastMixin {
final ValueNotifier<AvesEntry?> entryNotifier = ValueNotifier(null); final ValueNotifier<AvesEntry?> entryNotifier = ValueNotifier(null);
@ -51,7 +52,7 @@ class ViewerController with CastMixin {
this.autopilotAnimatedZoom = false, this.autopilotAnimatedZoom = false,
}) { }) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$ViewerController', className: '$ViewerController',
object: this, object: this,
@ -66,7 +67,7 @@ class ViewerController with CastMixin {
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
entryNotifier.removeListener(_onEntryChanged); entryNotifier.removeListener(_onEntryChanged);
windowService.setHdrColorMode(false); windowService.setHdrColorMode(false);

View file

@ -4,6 +4,7 @@ import 'package:aves/model/entry/entry.dart';
import 'package:aves/widgets/viewer/multipage/controller.dart'; import 'package:aves/widgets/viewer/multipage/controller.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:leak_tracker/leak_tracker.dart';
class MultiPageConductor { class MultiPageConductor {
final List<MultiPageController> _controllers = []; final List<MultiPageController> _controllers = [];
@ -12,7 +13,7 @@ class MultiPageConductor {
MultiPageConductor() { MultiPageConductor() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$MultiPageConductor', className: '$MultiPageConductor',
object: this, object: this,
@ -22,7 +23,7 @@ class MultiPageConductor {
Future<void> dispose() async { Future<void> dispose() async {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
await _disposeAll(); await _disposeAll();
_controllers.clear(); _controllers.clear();

View file

@ -5,6 +5,7 @@ import 'package:aves/model/entry/entry.dart';
import 'package:aves/model/entry/extensions/multipage.dart'; import 'package:aves/model/entry/extensions/multipage.dart';
import 'package:aves/model/multipage.dart'; import 'package:aves/model/multipage.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:leak_tracker/leak_tracker.dart';
class MultiPageController { class MultiPageController {
final AvesEntry entry; final AvesEntry entry;
@ -25,7 +26,7 @@ class MultiPageController {
MultiPageController(this.entry) { MultiPageController(this.entry) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$MultiPageController', className: '$MultiPageController',
object: this, object: this,
@ -48,7 +49,7 @@ class MultiPageController {
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
_info?.dispose(); _info?.dispose();
_disposed = true; _disposed = true;

View file

@ -10,6 +10,7 @@ import 'package:aves_model/aves_model.dart';
import 'package:aves_video/aves_video.dart'; import 'package:aves_video/aves_video.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:leak_tracker/leak_tracker.dart';
class VideoConductor { class VideoConductor {
final CollectionLens? _collection; final CollectionLens? _collection;
@ -21,7 +22,7 @@ class VideoConductor {
VideoConductor({CollectionLens? collection}) : _collection = collection { VideoConductor({CollectionLens? collection}) : _collection = collection {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$VideoConductor', className: '$VideoConductor',
object: this, object: this,
@ -31,7 +32,7 @@ class VideoConductor {
Future<void> dispose() async { Future<void> dispose() async {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
_subscriptions _subscriptions
..forEach((sub) => sub.cancel()) ..forEach((sub) => sub.cancel())

View file

@ -5,6 +5,7 @@ import 'package:aves_magnifier/aves_magnifier.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:leak_tracker/leak_tracker.dart';
class ViewStateConductor { class ViewStateConductor {
final List<ViewStateController> _controllers = []; final List<ViewStateController> _controllers = [];
@ -14,7 +15,7 @@ class ViewStateConductor {
ViewStateConductor() { ViewStateConductor() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$ViewStateConductor', className: '$ViewStateConductor',
object: this, object: this,
@ -24,7 +25,7 @@ class ViewStateConductor {
Future<void> dispose() async { Future<void> dispose() async {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
_controllers.forEach((v) => v.dispose()); _controllers.forEach((v) => v.dispose());
_controllers.clear(); _controllers.clear();

View file

@ -3,6 +3,7 @@ import 'package:aves/model/viewer/view_state.dart';
import 'package:aves/widgets/viewer/view/histogram.dart'; import 'package:aves/widgets/viewer/view/histogram.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:leak_tracker/leak_tracker.dart';
class ViewStateController with HistogramMixin { class ViewStateController with HistogramMixin {
final AvesEntry entry; final AvesEntry entry;
@ -16,7 +17,7 @@ class ViewStateController with HistogramMixin {
required this.viewStateNotifier, required this.viewStateNotifier,
}) { }) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( LeakTracking.dispatchObjectCreated(
library: 'aves', library: 'aves',
className: '$ViewStateController', className: '$ViewStateController',
object: this, object: this,
@ -26,7 +27,7 @@ class ViewStateController with HistogramMixin {
void dispose() { void dispose() {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this); LeakTracking.dispatchObjectDisposed(object: this);
} }
viewStateNotifier.dispose(); viewStateNotifier.dispose();
fullImageNotifier.dispose(); fullImageNotifier.dispose();