From 94a2b2c86d70c3f09432d0a4d89f0c4702ceb504 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 8 Jul 2021 12:16:40 -0700 Subject: [PATCH] Resolve T94204073 by swallowing errors Summary: At risk of hiding errors, given the low volume, I think it's safe to cause this to crash in debug and continue gracefully in release-mode. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D29618047 fbshipit-source-id: 19b19d8f6e27703227de4947ed01f7f2177f463b --- .../com/facebook/react/views/scroll/ScrollEvent.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java index 5b0c0c312be..d95c62a9782 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java @@ -11,12 +11,14 @@ import androidx.annotation.Nullable; import androidx.core.util.Pools; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.ReactSoftException; import com.facebook.react.bridge.WritableMap; import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.events.Event; /** A event dispatched from a ScrollView scrolling. */ public class ScrollEvent extends Event { + private static String TAG = ScrollEvent.class.getSimpleName(); private static final Pools.SynchronizedPool EVENTS_POOL = new Pools.SynchronizedPool<>(3); @@ -90,7 +92,13 @@ public class ScrollEvent extends Event { @Override public void onDispose() { - EVENTS_POOL.release(this); + try { + EVENTS_POOL.release(this); + } catch (IllegalStateException e) { + // This exception can be thrown when an event is double-released. + // This is a problem but won't cause user-visible impact, so it's okay to fail silently. + ReactSoftException.logSoftException(TAG, e); + } } private ScrollEvent() {}