-
-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<__NSArrayM: 0x60000327cff0> was mutated while being enumerated #849
Comments
Thanks for the issue. I hope we could have minimal reproduction. |
I've noticed the same issue but only in release iOS versions, I can't replicate it at all in debug with the IAP sandbox, it seems to happen randomly and doesn't consistently crash and it's not affecting every user. @kennym are you calling getAvailablePurchases() at all? As that seems to be what is causing the crash for me. @hyochan I think for me it happens when I check if the user has an active subscription using the snippet from this thread: #275 (comment) (I'm currently running react-native-iap 4.0.7) |
Hey guys, how are you? I'm also currently experiencing this issue in production and, given that I'm not an Objective-C developer, I tried to look into the code to see what's happening.
The issue happens at the line
and for what I have read, it has to do with multiple threads accessing the validProducts array at the same time, maybe because the method is being called multiple times in succession or something like that. On Stack Overflow, people have given 2 different solutions:
Do you think this is correct? Sorry if I'm being completely wrong about it, and thanks in advance. |
I am also facing the same problem. Could anyone help me with this |
In version react-native-iap@4.3.3 same issue. Occurs on various devices (iPhone 6S, X, 11 pro max, 7, 8 etc) and OS versions 13. * |
Wrap every access to validProducts in an @synchronized-Block. This might impact the performance but it fixes the crashes described in Issue hyochan#849 for me.
@vischnabel I'm not an Objectice-C developer myself but I added @synchronized to every access to validProducts as you proposed in your answer. As far as I can tell, this fixes the problem for me. I created the following pull-request: #957 |
We see several instances of this error occurring in the wild. It might be us calling
getProducts
more than once in rapid succession, but I wonder if there's some defensive coding we could put in place, to prevent this error?Version of react-native-iap
4.2.0
Version of react-native
0.61.4
Platforms you faced the error (IOS or Android or both?)
iOS
Expected behavior
No error
Actual behavior
Race condition
Tested environment (Emulator? Real Device?)
Real device/Emulator
Steps to reproduce the behavior
Unkown
The text was updated successfully, but these errors were encountered: