Unverified Commit e2d5e8fd authored by Binni Goel's avatar Binni Goel Committed by GitHub

Instrumented PipelineOwner for leak tracking (#137494)

parent 7308207c
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment