input-mask-android icon indicating copy to clipboard operation
input-mask-android copied to clipboard

fix ConcurrentModificationException when other text watchers are installed

Open dhvector opened this issue 1 year ago • 0 comments

I experienced this in a react-native app when using another library, LogRocket, which globally scans for text views to install their own text watcher for analytics purposes.

And along with react-native, I have these installed as well:

What triggers the crash is:

  1. when the React Native text component loops over an iterator
  2. this library's afterTextChanged is called which modifies the list while it's being iterated
  3. there are any other text watchers (e.g. LogRocket) that come after this one in the list.
  4. the iterator will try to fetch its next element, which fails with ConcurrentModificationException during the check for comodification.

If not for (3), the crash is avoided.

With this PR, I was able to substitute this library out for a patched one and confirmed it fixes the issue.

Let me know if you need anything else.

dhvector avatar Jan 24 '25 08:01 dhvector