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

[wayland] Animated webp image leaking memory #429

Open
lundmar opened this issue Nov 13, 2024 · 3 comments
Open

[wayland] Animated webp image leaking memory #429

lundmar opened this issue Nov 13, 2024 · 3 comments
Labels
memory leak Topics of memory leak wayland Topics of Wayland

Comments

@lundmar
Copy link

lundmar commented Nov 13, 2024

Environment: flutter-elinux v3.24.3, Yocto Kirkstone, NXP iMX8/ARM64, wayland.

We see memory leaking when running the following simple test application which features a 100 x 100 pixel webp image:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("Animated WebP Test")),
        body: Center(
          child: Image.asset("assets/images/minion100x100.webp"), // Leaking
          // child: Image.asset("assets/images/minion500x500.webp"), // Not leaking
        ),
      ),
    );
  }
}

Memory/CPU usage when running the test application for 3 hours:

go2elinux_1345_memory_cpu_usage

Memory usage keeps growing at a rate of about 3MB/hour.

Switching to another 500x500 pixel webp image does not leak:

go2elinux_1355_memory_cpu_usage

Both image files have passed the 'webpinfo' tool without any errors/warnings.

The image files are available here: https://github.com/lundmar/test-images

This issue seems to be specific to flutter-elinux since running the same application using desktop flutter in a flutter-3.24.4/Ubuntu-24.10/wayland environment does not leak.

We've been using valgrind to try identify the memory leak but valgrind seems to get confused by the dart VM and the few memory sizes that are reported definitely/indirectly/possibly lost stays the same over time, only "still reachable" memory changes but nowhere near the leak size we see for the application process. Attached are the valgrind logs for short (1-5 minute) and long (1 hour 30 minutes) runs for both test cases. There are some webp decode related functions mentioned in the still reachable loss records but it seems to give the same picture for both the leaking and not leaking test case.

100x100-valgrind-1h30m.log
100x100-valgrind-1m.log
500x500-valgrind-1h30m.log
500x500-valgrind-5m.log

@HidenoriMatsubayashi HidenoriMatsubayashi added wayland Topics of Wayland memory leak Topics of memory leak labels Nov 13, 2024
@HidenoriMatsubayashi
Copy link
Contributor

Probably this is the same issue as #274.

@lundmar
Copy link
Author

lundmar commented Nov 13, 2024

Probably this is the same issue as #274.

Maybe. Would it be possible for you to try run the test application on your flutter elinux setup to see if you can replicate?

If it is a GC issue it is definitely not recovering over time - here is a 9 hours test run:

go2elinux_1345_memory_cpu_usage

I'm not sure what to conclude from the rising CPU usage.

@lundmar
Copy link
Author

lundmar commented Nov 15, 2024

I let the leaking image test application run and we get this cpu/mem usage:

go2elinux_1726_memory_cpu_usage

After 43 hours the screen froze and the target had crashed in a way so I could not access it and I had to recycle it to login again. Unfortunately we do not have persistent journal log enabled so any application crash information is lost. I'll enable persistent logging and repeat the test in hope to get something useful from the logs that may help tell us what is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
memory leak Topics of memory leak wayland Topics of Wayland
Projects
None yet
Development

No branches or pull requests

2 participants