fixes: out if index exception when adding feature view#5795
fixes: out if index exception when adding feature view#5795salah-ghanim merged 2 commits intoreact-native-maps:masterfrom
Conversation
|
I've checked that this resolves #5750 with the provided reproduction repo |
@salah-ghanim I experienced same issue as described here: This PR fixes the issue for me. |
I am however still experiencing issue with android map markers being rendered in place of original markers. @CptFabulouso //edit I am using clustering, but it even if i disable it. Once i try to re-render markers from another screen, there are basic marker Android icons instead of Those that were detached (filtered out) and they stay visible no matter what (duplicate my markers if i reset filters). |
|
@maXXCZ1 No not in my use case. I'd like to look into it, but not sure if I'll find time for that :/ |
|
@CptFabulouso No, i tried but sadly no imprevements. But bug addressed with your PR is in my case solved, thanks. |
|
this crash happened once on prod with this changes. Not sure how to reproduce it. |
|
I fixed this issue by remove the map view when navigating away from the screen |
|
@code-strategist Thanks for your feedback. It's hard to tell, but it may be reanimated issue. Part of the error stack trace is similar to the stack trace in this issue software-mansion/react-native-reanimated#4470 |
|
@CptFabulouso Hi P, yes the map + marker are wrapped with a Reanimated.View. I'm using the version const AnimatedMarkerBase = Animated.createAnimatedComponent(
MapMarker as React.ComponentClass<MarkerProps>,
);Without clear reproducing on my side, it's hard to debug. |
code-strategist
left a comment
There was a problem hiding this comment.
@salah-ghanim please review, the changes have been been tested.
|
I've also confirmed this works. Tagging @GETAWAY-Dev as well (approved more recent PR's) |
|
Do you guys have an idea on when this fix can be released? I tested on Android 15 and it removed the error. Thank you for maintaining this package ❤️ |
|
🎉 This PR is included in version 1.26.19 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Does any other open PR do the same thing?
#5770 possibly tries to address similar issue, but fails. Although my primary focus was to fix #5781
What issue is this PR fixing?
#5781
Possibly also this #5750
How did you test this PR?
I have very similar setup to what the issues above specify, meaning problems after navigating away from the screen with map and navigating back. These changes seem to fix it for my use case.
PR explanation
When navigatin away from the screen,
onDetachedFromWindowlifecycle is called, which callsfeatures.clear().After navigating back to the screen, RN re-mounts the views (I think), and
addViewmethods are called (beforeonAttachedToWindow).The
addViewmay be called first with view at index 1, which ends up with IndexOutOfBoundsException, becausefeaturesware cleared and we must first add item at index 0.Only after views are added the
onAttachedToWindowis called.So the fix checks whether the component is detached (paused) and if so, saves the component into
savedFeaturesinstead and after theonAttachedToWindowis called, they get mounted via the existing code thereThat's also probably the reason why #5781 (comment) works, because I assume that prevents running the
onDetachedFromWindowlifecycle.