Skip to content

TapRegion will fire callback on other navigation's stack #153093

Closed

Description

@vfiruz97

Issue's explanation is that.
if we have TapRegion on our PageA and then we push to other PageB then we continue getting callback on TapRegion's onTapOutside when we make any contact with device's screen on PageB.

Steps to reproduce

  1. just run the following code
  2. open the terminal
  3. see the print from the onTapOutside of TapRegion of both Pages in the terminal

Expected results

EditPageElement not leak

we have to not see the print from one of the TapRegion callbacks because they are in different Pages.
when we open first page we click outside the red container we see the print from the onTapOutside of TapRegion. And ther we click onto FloatingActionButton to navigate to other page. There we have another TapRegion which works the same. And here we see the terminal that we are getting callback twice. One from the first page since that has to be disposed.

Actual results

EditPageElement leaked

Code sample

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Home'),
      ),
      body: Center(
        child: TapRegion(
          onTapOutside: (event) {
            print('From The First Page: $event');
          },
          child: Container(
            width: 100,
            height: 100,
            color: Colors.red,
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          Navigator.push(context, MaterialPageRoute(builder: (context) => const EditPage()));
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}

class EditPage extends StatelessWidget {
  const EditPage({super.key});

  @override
  StatelessElement createElement() => EditPageElement(this);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('EditPage')),
      body: Center(
        child: TapRegion(
          onTapOutside: (event) {
            print('From The Second Page: $event');
          },
          child: Container(
            width: 100,
            height: 100,
            color: Colors.red,
          ),
        ),
      ),
    );
  }
}

class EditPageElement extends StatelessElement {
  EditPageElement(super.widget);
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
From The First Page: _TransformedPointerDownEvent#92e5a(position: Offset(351.2, 276.2))
From The Second Page: _TransformedPointerDownEvent#83e76(position: Offset(136.1, 173.5))
From The First Page: _TransformedPointerDownEvent#fd16b(position: Offset(134.3, 188.6))
From The Second Page: _TransformedPointerDownEvent#fd16b(position: Offset(134.3, 188.6))
From The First Page: _TransformedPointerDownEvent#5df0f(position: Offset(16.1, 22.0))
From The Second Page: _TransformedPointerDownEvent#5df0f(position: Offset(16.1, 22.0))

Flutter Doctor output

Doctor output
➜  ~ flutter doctor                   

┌─────────────────────────────────────────────────────────┐
│ A new version of Flutter is available!                  │
│                                                         │
│ To update to the latest version, run "flutter upgrade". │
└─────────────────────────────────────────────────────────┘
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.0, on macOS 13.2.1 22D68 darwin-x64, locale
    en-TJ)
[✓] Android toolchain - develop for Android devices (Android SDK version
    34.0.0-rc2)
[!] Xcode - develop for iOS and macOS (Xcode 14.2)
    ! Flutter recommends a minimum Xcode version of 15.
      Download the latest version or update via the Mac App Store.
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.0)
[!] Connected device
    ! No devices available
[✓] Network resources```

</details>

Activity

  1. vfiruz97 commented on Aug 8, 2024

    @vfiruz97
    Author

    @matthew-carroll its quite similar you did. with UndoManager #148291

  2. darshankawar commented on Aug 9, 2024

    @darshankawar
    Member

    its quite similar you did. with UndoManager #148291

    @vfiruz97 This is fixed and available in latest stable 3.24.0. Can you upgrade to latest and re-run your scenario to check if the reported behavior still occurs or not ?

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 9, 2024
  4. vfiruz97 commented on Aug 10, 2024

    @vfiruz97
    Author

    its quite similar you did. with UndoManager #148291

    @vfiruz97 This is fixed and available in latest stable 3.24.0. Can you upgrade to latest and re-run your scenario to check if the reported behavior still occurs or not ?

    There is still this issue, have tried in latest stable 3.24.0

    Logs

    D/EGL_emulation( 4554): app_time_stats: avg=9211.86ms min=9211.86ms max=9211.86ms count=1
    I/flutter ( 4554): From The First Page: _TransformedPointerDownEvent#35b56(position: Offset(371.4, 729.1))
    I/flutter ( 4554): From The First Page: _TransformedPointerDownEvent#53c5a(position: Offset(142.8, 752.0))
    I/flutter ( 4554): From The First Page: _TransformedPointerDownEvent#75f96(position: Offset(377.1, 854.8))
    W/OnBackInvokedCallback( 4554): OnBackInvokedCallback is not enabled for the application.
    W/OnBackInvokedCallback( 4554): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
    D/EGL_emulation( 4554): app_time_stats: avg=8339.23ms min=8339.23ms max=8339.23ms count=1
    I/flutter ( 4554): From The First Page: _TransformedPointerDownEvent#74731(position: Offset(234.3, 635.8))
    I/flutter ( 4554): From The Second Page: _TransformedPointerDownEvent#74731(position: Offset(234.3, 635.8))
    I/flutter ( 4554): From The First Page: _TransformedPointerDownEvent#b91e4(position: Offset(179.0, 746.3))
    I/flutter ( 4554): From The Second Page: _TransformedPointerDownEvent#b91e4(position: Offset(179.0, 746.3))
    I/flutter ( 4554): From The First Page: _TransformedPointerDownEvent#1f9e5(position: Offset(163.8, 769.1))
    I/flutter ( 4554): From The Second Page: _TransformedPointerDownEvent#1f9e5(position: Offset(163.8, 769.1))
    

    Flutter doctor

    ➜  tap_region_test flutter doctor   
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.24.0, on macOS 13.2.1 22D68 darwin-x64, locale en-TJ)
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc2)
    [!] Xcode - develop for iOS and macOS (Xcode 14.2)
        ! Flutter recommends a minimum Xcode version of 15.
          Download the latest version or update via the Mac App Store.
    [✓] Android Studio (version 2024.1)
    [✓] VS Code (version 1.92.1)
    [✓] Connected device (1 available)
    [✓] Network resources
    
    ! Doctor found issues in 1 category.
    
  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 10, 2024
  6. darshankawar commented on Aug 12, 2024

    @darshankawar
    Member

    Thanks for the update. Seeing the same behavior on latest stable and master versions.

    Stable and master: 3.24.0

  7. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: gesturesflutter/packages/flutter/gestures repository.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Aug 12, 2024
  8. added
    P2Important issues not at the top of the work list
    on Aug 21, 2024
  9. changed the title [-]TapRegion will live after disposing and continues to call its callbacks in other widgets[/-] [+]TapRegion will fire callback on other navigation's stack[/+] on Aug 30, 2024
  10. jaybe78 commented on Sep 30, 2024

    @jaybe78

    any news ? Experiencing that issue as well

  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Oct 8, 2024
  12. github-actions commented on Oct 22, 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.

  13. locked as resolved and limited conversation to collaborators on Oct 22, 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

    P2Important issues not at the top of the work listf: gesturesflutter/packages/flutter/gestures repository.found in release: 3.24Found to occur in 3.24frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions