-
Notifications
You must be signed in to change notification settings - Fork 33
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
Android Issue: Exception in native call from JS #6
Comments
@geo-vi I have published a patch. That should handle the case of forwardRef. I haven't yet managed to look into the native error that you mentioned here. Are there any steps to reproduce this? |
hi, I've faced the same issue, with changing FlatList data too rapidly |
i don't have an example, but i guess you can try to reproduce with a timer, just add new elements in the interval |
i'm trying native module without js part, and i noticed that each time i change data for my list, ref handler is called, and if i call enable in ref i have this error, so i enable only once, and don't have this error, its something to do with ref and enable/disable functions calls |
@flexsurfer can you confirm what version are you using? |
yes |
@vishalnarkhede At least for me, the "Exception in a native call from JS" -issue results from calling the enable or disable methods many times quickly. This is because the if-statement in the resetMvcpIfNeeded function are not comparing the right things. They are comparing the current value of the refs to the values in the props, but if some props are not defined (either autoscrollToTopThreshold or minIndexForVisible), then the refs are assigned a default value, which will always be different to the value in the props. This will result to the if-statement resolving to false each time resetMvcpIfNeeded is ran, causing the disable and enable functions to run too often. I fixed this by changing the ||-assignments from the ref.current assignments to the enableMaintainVisibleContentPosition function call.
|
Thanks @k4rriL I will look into it today :) |
@vishalnarkhede Thanks for looking into this. Any updates on this issue? |
@rgbedin I am looking into in as I type this :D |
@k4rriL Thanks for pointing this out, I see the issue now. Poor testing from my side, apologies :) |
Published v0.0.8 |
It seems to be working now. I am not getting this crash anymore. However is it expected that my // listRef.current is always undefined
<FlatList
ref={listRef}
... /> |
@rgbedin I noticed this as well and traced it to the |
@vishalnarkhede Thank you, it does not crash anymore 👍 But now I have another issue where the Flatlist does not initially maintain its position. When I live reload or use it for a while and refresh the application it starts working. This is my current config: It would also seem that in the row 45 of flatlist, this expression: |
@rgbedin Can you try ref as callback? |
@karri-lehtiranta I will take a look soon. Thanks for brining it up :) |
That does work. Code for reference: <FlatList
ref={(r) => (listRef.current = r)}
...
/> However I actually get the same bug @karri-lehtiranta reported. My list does not maintain its position properly and I have the same configurations reported. |
It seemed like the resetMvcpIfNeeded function needed to fully run multiple times in order for the maintaining of the position to work which was previously achieved because of the issue in the if-clauses that caused the crashes. And now while that is fixed the flatlist fails to maintain the position. |
hmm this is interesting. I think the error was coming from So maybe we need to switch back to executing ---- Update Tomorrow I will try to dig a bit more on native side, if we can find some solution there |
@karri-lehtiranta @rgbedin any thoughts? |
I removed the if-clause that was checking whether to run When I initially debugged the problem, the native exception that was thrown in native side was java.util.ConcurrentModificationException which I think occurs when trying to edit a list while its been iterated which was happening with the native UIManager which I deduced the cause to be that the UIManagerListeners were added and removed so quickly that the ConcurrentModificationException was thrown. Hopefully this helps you somehow @vishalnarkhede |
@karri-lehtiranta thanks alot. I think that definitely helps. Bdw, do you have some |
Yes, I have a |
@karri-lehtiranta @rgbedin So I was trying to mess around some logic, and this looks like a decent middle ground: https://github.com/GetStream/flat-list-mvcp/pull/11/files I have published Basically if you have some Thanks in advance |
Yeah it works much better now, thank you @vishalnarkhede, seems debounce did the trick. I just have a little problem still. The list does not maintain the position the first time it changes, after that it works well. So when I scroll upwards and load more content, the list jumps to the start of that new content once and if I scroll upwards again, it will correctly stay at the right position when I prepend more data to the list. |
Thanks for checking @karri-lehtiranta , I am looking into it. I am able to see the issue as well. Scroll jumps halfway for me on first pagination call. |
But happy to know that atleast partly its fixed |
@karri-lehtiranta so couple of things:
Please let me know how it goes!! The implementation is not exactly pretty to look at, but I want to first resolve all these issues, and then can clean up the code haha :) |
I usually have 5-10 items in the list in the beginning, but with EDIT: 80% might be around 90-95% instead, it is working quite well now. |
Thats wierd, I am trying really hard to reproduce crash after new changes ... but not able to :D |
Have published |
I have the same error with "@stream-io/flat-list-mvcp": "^0.0.9", "react-native-bidirectional-infinite-scroll": "^0.3.2", |
@karri-lehtiranta Could you please upgrade to |
Also @geo-vi @flexsurfer ^^ |
Published |
This occurs on Android when changing FlatList data too rapidly
In addition to that there is a ref issue in the code - you assign an unnecessary ref and also block on the way the forwarded ref
I'll submit a PR for the refs however, I still would like an insight on why it drops that error
The text was updated successfully, but these errors were encountered: