Skip to content

Commit

Permalink
remove unnecessary instrumentation from picture
Browse files Browse the repository at this point in the history
  • Loading branch information
yjbanov committed Apr 18, 2023
1 parent 7ffaec6 commit e24490c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lib/web_ui/lib/src/engine/canvaskit/picture.dart
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
}
Expand Down
39 changes: 39 additions & 0 deletions lib/web_ui/test/canvaskit/native_memory_test.dart
Expand Up @@ -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, () {
Expand Down

0 comments on commit e24490c

Please sign in to comment.