Skip to content

CkPicture not disposed #142381

Closed
Closed

Description

@curt-weber

Steps to reproduce

  1. Run sample in web
  2. Observe log with leaks
  3. CkPicture leaks have no detailed/retaining path

This leak only applies to the web platform. Tried to check the phases to see if there was already an issue for this but couldn't find it.
cc @polina-c

Expected results

CkPicture doesn't leak when new frames are pumped.

Actual results

CkPicture leaks frequently, likely due to new frames as they won't leak without new frames. (sample uses CircularProgressIndicator to constantly request new frames).

Code sample

Code sample
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:leak_tracker/leak_tracker.dart';

void main() {
  LeakTracking.start(
    config: const LeakTrackingConfig(onLeaks: _onLeaks),
  );

  FlutterMemoryAllocations.instance.addListener(
    (event) => LeakTracking.dispatchObjectEvent(event.toMap()),
  );

  runApp(
    const MaterialApp(
      home: Center(
        child: CircularProgressIndicator(),
      ),
    ),
  );
}

Future<void> _onLeaks(LeakSummary summary) async {
  final leaks = await LeakTracking.collectLeaks();
  for (final leak in leaks.all) {
    print(leak.toYaml('', phasesAreTests: false));
  }
}

Screenshots or Video

No response

Logs

Logs
CkPicture:
  identityHashCode: 599787274
...
leak_tracker: 262 memory leak(s): not disposed: 262, not GCed: 0, GCed late: 0

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 3.19.0-9.0.pre.204, on Microsoft Windows [Version 10.0.19044.3803], 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.85.2)
[√] Connected device (3 available)
[√] Network resources

Activity

  1. added
    a: leak tracking
    on Jan 28, 2024
  2. self-assigned this
    on Jan 29, 2024
  3. polina-c commented on Jan 29, 2024

    @polina-c
    Contributor

    Thanks a lot for reporting this!!!

    Steps to repro use leak tracker not in a way that is not currently tested and recommended. Can you create a widget test using this guidance and check if leaks are still detected: https://github.com/dart-lang/leak_tracker/blob/main/doc/leak_tracking/DETECT.md#test-cover-with-testwidgets

  4. removed their assignment
    on Jan 29, 2024
  5. added
    waiting for response
    on Jan 29, 2024
  6. curt-weber commented on Jan 30, 2024

    @curt-weber
    Author

    Yep, I figured it was pre-emptive, I was using the live detector to locate and fix some other leaks and noticed this one likely coming from the framework. I can try to repro with testWidgets, but it says in that document you linked that web platform isn't supported yet - should I wait then? Since this leak was only observed on web. Thanks for all your great work on this!

  7. removed
    waiting for response
    on Jan 30, 2024
  8. polina-c commented on Jan 30, 2024

    @polina-c
    Contributor

    Then I suggest instead of using leak tracker (that does not support reliably both web apps and running app yet), just to add temporary counting for CkPicture in your local copy of Flutter: increase global counter in constructor and decrease it in dispose. It will give you idea how many insstances are created and not disposed.
    If the number turns to 0 when you stop displaying the indicator, there is no leak.

    How does it sound?

  9. added
    waiting for response
    on Jan 30, 2024
  10. github-actions commented on Feb 20, 2024

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
    Thanks for your contribution.

  11. github-actions commented on Mar 5, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  12. locked as resolved and limited conversation to collaborators on Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: leak trackingwaiting for response

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions