react-native-maps: Android Crashes java.lang.IndexOutOfBoundsException: Index: 235, Size: 225
Summary
Hey, on the initial mount, android crashes. It starts in the 1.21.0 version and it is still present in the 1.23.7 version.
I get this error:
Reproducible sample code
<MapView
ref={map}
superClusterRef={superCluster}
initialRegion={
location.latitude && location.longitude
? {
latitude: location.latitude,
longitude: location.longitude,
latitudeDelta: DEFAULT_LAT_DELTA,
longitudeDelta: DEFAULT_LNG_DELTA,
}
: appConfig.MAP.INITIAL_REGION
}
toolbarEnabled={false}
animationEnabled={false}
showsUserLocation={!!permissions.locationGranted}
showsMyLocationButton={false}
style={styles.map}
radius={40}
onPress={onMapPress}
onPanDrag={onMapDrag}
renderCluster={renderCluster}
googleRenderer="LATEST"
{...otherProps}
>
{markers}
</MapView>
interface Props {
coordinate: { latitude: number; longitude: number };
onMarkerPress?: (markerRef: MapMarker | null) => void;
}
const Marker = ({ coordinate, onMarkerPress }: Props) => {
const ref = useRef<MapMarker>(null);
return (
<DefaultMarker
ref={ref}
centerOffset={{ x: 0.0, y: -26 }}
coordinate={coordinate}
tracksViewChanges={false}
image={{ uri: appConfig.MAP.MARKER_IMAGE }}
style={styles.marker}
pinColor={COLORS['solid/blue']}
zIndex={1}
onPress={() => {
if (onMarkerPress) {
onMarkerPress(ref.current);
}
}}
></DefaultMarker>
);
};
export default memo(Marker);
const styles = StyleSheet.create({
marker: {
width: 43,
height: 52,
},
});
Steps to reproduce
I also use “react-native-map-clustering” version 3.4.2.
Expected result
App not crashing
Actual result
App crashes
React Native Maps Version
1.23.7
What platforms are you seeing the problem on?
Android
React Native Version
0.76.9
What version of Expo are you using?
SDK 52
Device(s)
Honor, Android 9
Additional information
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 20
@salah-ghanim Any movement on this?
https://github.com/ammar-madni/repro-index-out-of-bounds
The repro above is pretty simple, when you first load the app the marker data is generated. The second time will be from the cache and thats what crashes the app with the index out of bounds exception.
Let me know if there is anything else I can do to help make this issue easier to debug and resolve.
@ammar-madni It Works!
@scottaglia Can you try clamping the index in the getFeatureAt method as below: