Skip to content

Commit 94a2b2c

Browse files
JoshuaGrossfacebook-github-bot
authored andcommitted
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
1 parent fb386fc commit 94a2b2c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import androidx.core.util.Pools;
1212
import com.facebook.infer.annotation.Assertions;
1313
import com.facebook.react.bridge.Arguments;
14+
import com.facebook.react.bridge.ReactSoftException;
1415
import com.facebook.react.bridge.WritableMap;
1516
import com.facebook.react.uimanager.PixelUtil;
1617
import com.facebook.react.uimanager.events.Event;
1718

1819
/** A event dispatched from a ScrollView scrolling. */
1920
public class ScrollEvent extends Event<ScrollEvent> {
21+
private static String TAG = ScrollEvent.class.getSimpleName();
2022

2123
private static final Pools.SynchronizedPool<ScrollEvent> EVENTS_POOL =
2224
new Pools.SynchronizedPool<>(3);
@@ -90,7 +92,13 @@ public static ScrollEvent obtain(
9092

9193
@Override
9294
public void onDispose() {
93-
EVENTS_POOL.release(this);
95+
try {
96+
EVENTS_POOL.release(this);
97+
} catch (IllegalStateException e) {
98+
// This exception can be thrown when an event is double-released.
99+
// This is a problem but won't cause user-visible impact, so it's okay to fail silently.
100+
ReactSoftException.logSoftException(TAG, e);
101+
}
94102
}
95103

96104
private ScrollEvent() {}

0 commit comments

Comments
 (0)