Skip to content

GestureDetecor leaks ScreenStackFragment once interacted with #3941

@chairly89

Description

@chairly89

Description

Placing a GestureDetector on a screen and interacting with the GestureDetector, such as pinching or panning, causes the entire ScreenStackFragment to leak on Android when combined with Expo Router (not tested iOS yet).

This is particularly an issue if the screen contains heavy objects such as Bitmaps, as these are failing to be garbage collected as well.

Image

Steps to reproduce

Minimum example repo available here: https://github.com/chairly89/rn-gesture-detector-memory-leak

  1. Open the app and navigate to the second screen using the button in the center of the screen
  2. Attempt to pinch or pan on this view (this won't do anything, as no implementation has been added)
  3. Use the back button to go back to the first screen.
  4. Open the Android Studio Profiler and there will be a ScreenStackFragment that has not been dereferences and can't be garbage collected.

A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.

https://github.com/chairly89/rn-gesture-detector-memory-leak

Gesture Handler version

2.28.0

React Native version

0.81.5

Platforms

Android

JavaScript runtime

Hermes

Workflow

Using Expo Prebuild or an Expo development build

Architecture

New Architecture (Fabric)

Build type

Debug mode

Device

Android emulator

Device model

Pixel 9

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: AndroidThis issue is specific to AndroidRepro providedA reproduction with a snack or repo is provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions