Skip to content

ContextMenuController does not dispose OverlayEntry. #130467

Description

@polina-c

To repro:

  1. Remove notDisposedAllowList from packages/flutter/test/material/text_form_field_test.dart
  2. Then see the modified test is failing

PR that adds notDisposedAllowList: #130468

Creation call stack: https://raw.githubusercontent.com/polina-c/spikes/master/notes/failures/2023-July-12/text_form_field_test_107.txt

Activity

  1. changed the title [-]ValueNotifier<_OverlayEntryWidgetState?> is not disposed.[/-] [+]ContextMenuController does not dispose OverlayEntry.[/+] on Jul 13, 2023
  2. added
    in triagePresently being triaged by the triage team
    on Jul 13, 2023
  3. huycozy commented on Jul 13, 2023

    @huycozy
    Member

    Hi @polina-c
    I can't find notDisposedAllowList from packages/flutter/test/material/text_form_field_test.dart. Could you give a simple use case of ContextMenuController that causes this issue?

  4. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 13, 2023
  5. polina-c commented on Jul 13, 2023

    @polina-c
    ContributorAuthor

    notDisposedAllowList is added by PR that is linked in description: https://github.com/flutter/flutter/pull/130468/files

  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 13, 2023
  7. polina-c commented on Jul 13, 2023

    @polina-c
    ContributorAuthor

    Feel free to tweet me or to chat me, to setup GVC. I will be happy to explain details.

  8. added
    a: tests"flutter test", flutter_test, or one of our tests
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Jul 14, 2023
  9. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 17, 2023
  10. polina-c commented on Jul 17, 2023

    @polina-c
    ContributorAuthor
  11. added
    in triagePresently being triaged by the triage team
    and removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 17, 2023
  12. goderbauer commented on Jul 25, 2023

    @goderbauer
    Member
  13. justinmc commented on Jul 26, 2023

    @justinmc
    Contributor
    • When the test is run with testWidgetsWithLinkTracking, then the EditableTextState (and the whole widget tree in pumpWidget?) is never disposed at the end of the test. If I change it to testWidgets, then it is disposed.
    • (Using testWidgetsWithLinkTracking) Bizarrely, if I comment out this line where _handles is set to null, then EditableTextState does get disposed. This is true even if I hack out all of the accesses of _handles after it's set to null, leading me to think something deep behind the scenes is doing this.

    @polina-c Is there anything that testWidgetsWithLeakTracking does that could prevent the widget tree from being disposed?

    Here's a simpler test that still reproduces the problem:
      testWidgetsWithLeakTracking('leak test', (WidgetTester tester) async {
        final TextEditingController controller = TextEditingController(
          text: 'blah1 blah2',
        );
        await tester.pumpWidget(
          MaterialApp(
            home: Material(
              child: Center(
                child: TextField(
                  controller: controller,
                ),
              ),
            ),
          ),
        );
    
        final Offset startBlah1 = textOffsetToPosition(tester, 0);
        await tester.tapAt(startBlah1);
        await tester.pump(const Duration(milliseconds: 100));
        await tester.tapAt(startBlah1);
        await tester.pumpAndSettle();
      },
        variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.macOS }),
        skip: kIsWeb, // [intended] we don't supply the cut/copy/paste buttons on the web.
      );
  14. polina-c commented on Jul 27, 2023

    @polina-c
    ContributorAuthor

    Thanks. For some reasons with leak tracker BuildOwner.finalizeTree is invoked 6 times instead of 7, where 7th one triggers disposal.

    At the moment I am refactoring leak tracker for performance, that may side effect in this side effect disappearing.
    So, reassigning the issue to me and shelving till after refactoring.

  15. self-assigned this
    on Jul 27, 2023
  16. added
    P1High-priority issues at the top of the work list
    and removed
    in triagePresently being triaged by the triage team
    on Jul 27, 2023
  17. polina-c commented on Aug 17, 2023

    @polina-c
    ContributorAuthor

    @justinmc

    It seems flakiness disappeared. Returning the issue to you. Remaining leaks:

    notDisposed:
                  total: 4
                  objects:
                    RestorableBool:
                      test: can use the desktop cut/copy/paste buttons on Windows and Linux
                      identityHashCode: 1004453175
                    RestorableStringN:
                      test: can use the desktop cut/copy/paste buttons on Windows and Linux
                      identityHashCode: 715878348
                    RestorableBool:
                      test: can use the desktop cut/copy/paste buttons on Windows and Linux
                      identityHashCode: 69970577
                    RestorableStringN:
                      test: can use the desktop cut/copy/paste buttons on Windows and Linux
                      identityHashCode: 283658580
    

    To see callstack for creation, set this config:

    leakTrackingTestConfig: const LeakTrackingTestConfig.debugnotDisposed() 
    
  18. github-actions commented on Sep 5, 2023

    @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.

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

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: tests"flutter test", flutter_test, or one of our testsa: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesteam-designOwned by Design Languages team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions