Skip to content

Conversation

@j-piasecki
Copy link
Member

Description

Should fix #1639

The IndexOutOfBoundsException was thrown at line 387:

ArrayList<GestureHandler> handlers = mHandlerRegistry.getHandlersForView(view);
boolean found = false;
if (handlers != null) {
for (int i = 0, size = handlers.size(); i < size; i++) {
GestureHandler handler = handlers.get(i);
if (handler.isEnabled() && handler.isWithinBounds(view, coords[0], coords[1])) {

So the handlers collection must have been modified in other place and the registry is the only class that modifies it. My guess is that the handler was dropped or removed from view and relevant method was called (asynchronously)
causing the list to be modified while it was being iterated over. This PR locks the list while it's being modified or iterated over.

Test plan

I couldn't reproduce the issue, but I tested the changes on the Example app and it works correctly.

@j-piasecki j-piasecki merged commit ceec9f8 into software-mansion:main Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.lang.IndexOutOfBoundsException: Index: 1, Size: 0

2 participants