From 18c5bb07d34f4aa8aa865d05b80ffe6fed9ab0ac Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 3 May 2024 03:15:52 +0800 Subject: [PATCH] Fix dangling surfaces in ReactHostImpl --- .../main/java/com/facebook/react/runtime/ReactHostImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java index 5ab8c2a7411965..d9406fc00b7592 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java @@ -1543,9 +1543,9 @@ private Task getOrCreateDestroyTask(final String reason, @Nullable Excepti // Step 3: Stop all React Native surfaces stopAttachedSurfaces(method, reactInstance); - - // TODO(T161461674): Should we clear mAttachedSurfaces? - // Not clearing mAttachedSurfaces could lead to a memory leak. + synchronized (mAttachedSurfaces) { + mAttachedSurfaces.clear(); + } return task; },