[web:canvaskit] remove unnecessary instrumentation from picture (flutter/engine#41313)

Remove unnecessary instrumentation from picture. `UniqueRef`
automatically instruments all allocations, disposals, and garbage
collections, which covers `CkPicture`.
This commit is contained in:
Yegor
2023-04-18 16:49:00 -07:00
committed by GitHub
parent 7909cdcbbe
commit d5474b17ac
2 changed files with 39 additions and 4 deletions

View File

@@ -6,7 +6,6 @@ import 'dart:typed_data';
import 'package:ui/ui.dart' as ui;
import '../profiler.dart';
import '../util.dart';
import 'canvas.dart';
import 'canvaskit_api.dart';
@@ -77,9 +76,6 @@ class CkPicture implements ui.Picture {
return true;
}());
ui.Picture.onDispose?.call(this);
if (Instrumentation.enabled) {
Instrumentation.instance.incrementCounter('Picture disposed');
}
_isDisposed = true;
_ref.dispose();
}

View File

@@ -81,6 +81,45 @@ void testMain() {
// there must not be anything else calling into this object for anything
// useful.
});
test('dispose instrumentation', () {
Instrumentation.enabled = true;
Instrumentation.instance.debugCounters.clear();
final Object owner = Object();
final TestSkDeletable nativeObject = TestSkDeletable();
expect(Instrumentation.instance.debugCounters, <String, int>{});
final UniqueRef<TestSkDeletable> ref = UniqueRef<TestSkDeletable>(owner, nativeObject, 'TestSkDeletable');
expect(Instrumentation.instance.debugCounters, <String, int>{
'TestSkDeletable Created': 1,
});
ref.dispose();
expect(Instrumentation.instance.debugCounters, <String, int>{
'TestSkDeletable Created': 1,
'TestSkDeletable Deleted': 1,
});
});
test('collect instrumentation', () {
Instrumentation.enabled = true;
Instrumentation.instance.debugCounters.clear();
final Object owner = Object();
final TestSkDeletable nativeObject = TestSkDeletable();
expect(Instrumentation.instance.debugCounters, <String, int>{});
final UniqueRef<TestSkDeletable> ref = UniqueRef<TestSkDeletable>(owner, nativeObject, 'TestSkDeletable');
expect(Instrumentation.instance.debugCounters, <String, int>{
'TestSkDeletable Created': 1,
});
ref.collect();
expect(Instrumentation.instance.debugCounters, <String, int>{
'TestSkDeletable Created': 1,
'TestSkDeletable Leaked': 1,
'TestSkDeletable Deleted': 1,
});
});
});
group(CountedRef, () {