-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#54096Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: leak trackingIssues and PRs related to memory leaks detected by leak_trackerIssues and PRs related to memory leaks detected by leak_trackera: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testse: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for WebCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webfound in release: 3.19Found to occur in 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memoryPerformance issues related to memoryplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamOwned by Web platform teamtriaged-webTriaged by Web platform teamTriaged by Web platform team
Description
Steps to reproduce
- Run tests below on a non-web platform
- Tests should pass
- Run tests below on web platform
- instantiateImageCodecWithSize will fail
Expected results
Both tests should pass on all platforms. instantiateImageCodecWithSize on web is not disposing of the original imagery following conversion to the target size. cc @polina-c - this is similar to an issue I opened previously, but here are tests demonstrating the leak.
Actual results
Both tests pass on non-web platforms. The second test, which evaluates if instantiateImageCodecWithSize is leaking, fails on web.
Code sample
Code sample
import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter_test/flutter_test.dart';
void main() {
late final Uint8List bytes;
final loaded = <Image>{};
setUpAll(() async {
final image = await createTestImage(width: 500, height: 500);
final data = await image.toByteData(format: ImageByteFormat.png);
bytes = data!.buffer.asUint8List();
image.dispose();
Image.onCreate = loaded.add;
Image.onDispose = loaded.remove;
});
tearDownAll(() {
Image.onCreate = null;
Image.onDispose = null;
});
tearDown(loaded.clear);
test('instantiateImageCodec', () async {
expect(loaded.length, 0);
final codec = await instantiateImageCodec(bytes);
final frame = await codec.getNextFrame();
expect(loaded.length, 1);
frame.image.dispose();
codec.dispose();
expect(loaded.length, 0);
});
test('instantiateImageCodecWithSize', () async {
expect(loaded.length, 0);
final codec = await instantiateImageCodecWithSize(
await ImmutableBuffer.fromUint8List(bytes),
getTargetSize: (_, __) => const TargetImageSize(width: 250, height: 250),
);
final frame = await codec.getNextFrame();
expect(loaded.length, 1);
frame.image.dispose();
codec.dispose();
expect(loaded.length, 0);
});
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
No response
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.19044.4170], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.3.5)
[√] Android Studio (version 2021.3)
[√] VS Code (version 1.88.1)
[√] Connected device (3 available)
[√] Network resources
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: leak trackingIssues and PRs related to memory leaks detected by leak_trackerIssues and PRs related to memory leaks detected by leak_trackera: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testse: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for WebCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webfound in release: 3.19Found to occur in 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memoryPerformance issues related to memoryplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamOwned by Web platform teamtriaged-webTriaged by Web platform teamTriaged by Web platform team