Instrumented PipelineOwner for leak tracking (#137494)
This commit is contained in:
@@ -895,7 +895,17 @@ class PipelineOwner with DiagnosticableTreeMixin {
|
||||
this.onSemanticsOwnerCreated,
|
||||
this.onSemanticsUpdate,
|
||||
this.onSemanticsOwnerDisposed,
|
||||
});
|
||||
}){
|
||||
// TODO(polina-c): stop duplicating code across disposables
|
||||
// https://github.com/flutter/flutter/issues/137435
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
MemoryAllocations.instance.dispatchObjectCreated(
|
||||
library: 'package:flutter/rendering.dart',
|
||||
className: '$PipelineOwner',
|
||||
object: this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when a render object associated with this pipeline owner wishes to
|
||||
/// update its visual appearance.
|
||||
@@ -1433,6 +1443,9 @@ class PipelineOwner with DiagnosticableTreeMixin {
|
||||
assert(rootNode == null);
|
||||
assert(_manifold == null);
|
||||
assert(_debugParent == null);
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
MemoryAllocations.instance.dispatchObjectDisposed(object: this);
|
||||
}
|
||||
_semanticsOwner?.dispose();
|
||||
_semanticsOwner = null;
|
||||
_nodesNeedingLayout.clear();
|
||||
|
||||
@@ -8,12 +8,20 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
import 'rendering_tester.dart';
|
||||
|
||||
void main() {
|
||||
TestRenderingFlutterBinding.ensureInitialized();
|
||||
|
||||
test('PipelineOwner dispatches memory events', () async {
|
||||
await expectLater(
|
||||
await memoryEvents(() => PipelineOwner().dispose(), PipelineOwner),
|
||||
areCreateAndDispose,
|
||||
);
|
||||
});
|
||||
|
||||
test('ensure frame is scheduled for markNeedsSemanticsUpdate', () {
|
||||
// Initialize all bindings because owner.flushSemantics() requires a window
|
||||
final TestRenderObject renderObject = TestRenderObject();
|
||||
|
||||
Reference in New Issue
Block a user