Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web:canvaskit] remove unnecessary instrumentation from picture #41313

Merged
merged 1 commit into from Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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