Repository navigation
Flutter framework is leaking in debug mode for gallery app. #107338
Description
Activity
Why it is important to fix:
- We want the leak detector tool to be valuable in both debug and profile mode
- We want debug memory footprint to be close to release one
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Jul 11, 2022 Hi @polina-c, Thanks for filing the issue. Labeling the issue for further investigation from the team.
- addedframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.c: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)perf: memoryPerformance issues related to memoryPerformance issues related to memoryplatform-macosBuilding on or for macOS specificallyBuilding on or for macOS specificallya: desktopRunning on desktopRunning on desktopand removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Jul 11, 2022 The file in the Google Drive seems private to me. Can you make sure it is publicly accessible?
The file in the Google Drive seems private to me. Can you make sure it is publicly accessible?
Fixed. Let me know if something is still wrong.
Reacted by Tong MuThe leaking state seems to be
EditableTextState. @LongCatIsLooong Can you take a look?
Also in a scroll view. cc @PiinksReacted by LongCatIsLooongSo far I've been unable to reproduce this.
I tried running the https://github.com/polina-c/flutter/tree/leak-tracking2 branch of the framework with a compatible version of Gallery (flutter-team-archive/gallery@1dfcd61)
I then added this to
main():WidgetsFlutterBinding.ensureInitialized(); startAppLeakTracking( enabledFamilies: {'flutterRendering'}, );Next I started Gallery, went to the Crane screen, resized the window, and scrolled through the list. Initially I did not get any reports of leaks.
However, after a few more seconds of scrolling I got a native code crash in the Dart runtime (apparently related to a stack overflow):
../../third_party/dart/runtime/vm/object_service.cc: 1738: error: unreachable code version=2.17.0 (stable) (Mon May 9 10:36:47 2022 +0200) on "macos_x64" pid=78442, thread=27651, isolate_group=main(0x7f81f2812800), isolate=main(0x7f81f0829000) isolate_instructions=114cca540, vm_instructions=114cca540 pc 0x0000000114e28c15 fp 0x00007000029320b0 dart::Profiler::DumpStackTrace(void*)+0x85 pc 0x0000000114cca754 fp 0x0000700002932190 dart::Assert::Fail(char const*, ...) const+0x84 pc 0x0000000114e20f7c fp 0x00007000029321b0 dart::FinalizerEntry::PrintJSONImpl(dart::JSONStream*, bool) const+0x2c pc 0x0000000114d20e95 fp 0x0000700002932260 dart::ActivationFrame::PrintToJSONObjectRegular(dart::JSONObject*)+0x375 pc 0x0000000114ea117d fp 0x00007000029322b0 dart::ServiceEvent::PrintJSON(dart::JSONStream*) const+0x3cd pc 0x0000000114d46101 fp 0x0000700002932420 dart::Isolate::PrintJSON(dart::JSONStream*, bool)+0x5f1 pc 0x0000000114e8908e fp 0x0000700002932570 dart::Service::InvokeMethod(dart::Isolate*, dart::Array const&, bool)+0x32e pc 0x0000000114e896c3 fp 0x00007000029325a0 dart::Service::HandleIsolateMessage(dart::Isolate*, dart::Array const&)+0x23 pc 0x0000000114d41223 fp 0x0000700002932680 dart::IsolateMessageHandler::HandleMessage(std::__1::unique_ptr<dart::Message, std::__1::default_delete<dart::Message> >)+0x283 pc 0x0000000114d70453 fp 0x0000700002932700 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)+0x133 pc 0x0000000114d70874 fp 0x0000700002932740 dart::MessageHandler::HandleOOBMessages()+0x54 pc 0x0000000114eb6428 fp 0x0000700002932780 dart::Thread::HandleInterrupts()+0x108 pc 0x0000000114e7fba4 fp 0x0000700002932950 dart::DRT_StackOverflow(dart::NativeArguments)+0x7a4 pc 0x00000001221825c3 fp 0x0000700002932998 Unknown symbolI also tried checking the Dart Observatory allocation profile while scrolling through Crane with the leak detector disabled. But I did not notice anything unusual.
@jason-simmons , thanks for checking. Yes, crash happens sometimes for me. But other times I see leaks. Can we have GVC session? I sent you invite.
Had discussion with Jason. Discoveries are:
- Gallery crashes for Jason every time, while it crashes for me ~5% of times. Most likely it is because my mac is newer.
- We found discrepancy between heap snapshot and observatory: while the snapshot contains the leaking object _RenderEditableCustomPaint, observatory shows there is no instances.
- addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Jul 14, 2022 Merged https://github.com/polina-c/flutter/tree/leak-tracking2 with flutter muster to make troubleshooting easier.
I tested it with Flutter 3.0.1-0.0.pre.1889 and could not repro both crash and leaks.
Closing.Reacted by Mahesh JamdadeThis 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 -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Aug 9, 2022
Steps to repro:
startAppLeakTracking(enabledFamilies: {'flutterRendering'});If you remove WeakRef from DebugCreator (the WeakRef is here just in the flutter branch for the leak tracker), you will get the leaks earlier, on main screen of gallery, by resizing and scrolling:
https://github.com/polina-c/flutter/blob/0b01eaaf89ddde670fb5494d49be059f172c8c70/packages/flutter/lib/src/widgets/framework.dart#L6394
Commenting out this line does not fix the issue:
flutter/packages/flutter/lib/src/rendering/object.dart
Line 258 in d01c0bc