rnmapbox / rnmapbox/maps

[Bug]: Crash when changing Annotations source state in iOS

Open
#3,419 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug 🪲
Dominant language
Kotlin
Stars
2.9k
Forks
947
Avg merge
6d 37m
Merged PRs (30d)
1

Description

Mapbox Implementation

Mapbox

Mapbox Version

default

React Native Version

0.73.4

Platform

iOS

@rnmapbox/maps version

10.1.19

Standalone component to reproduce
/* eslint-disable react/prop-types */
import {View, Text, StyleSheet, Button} from 'react-native';
import React, {useEffect, useRef, useState} from 'react';

import Mapbox, {Callout, Camera} from '@rnmapbox/maps';


export default function MapsPage() {
  var mapRef = useRef();

  const markers1 = [
    {
      cord: [2.0, -2.9999],
      isFav: true,
    },
    {
      cord: [5.044, -2.9999],
      isFav: true,
    },
    {
      cord: [9.044, -3.999],
      isFav: false,
    },
  ];

  const markers2 = [
    {
      cord: [3.0, -5.9999],
      isFav: true,
    },
    {
      cord: [4.044, -9.9999],
      isFav: true,
    },
    {
      cord: [9.044, -11.999],
      isFav: false,
    },
  ];
  var [markers, setmarkers] = useState(markers1);

  useEffect(() => {
    setmarkers(markers1);
  }, []);

  const MyTxt = ({item}) => {
    return (
      <View style={{height: 20, backgroundColor: 'green'}}>
        <Text>Jam</Text>
      </View>
    );
  };

  return (
    <View style={styles.page}>
      <View style={styles.container}>
        <Mapbox.MapView style={styles.map}>
          <Mapbox.Camera
            defaultSettings={{
              centerCoordinate: [2.0, -2.9999],
              zoomLevel: 4,
            }}
          />

          {markers.map(item => {
            return (
              <Mapbox.PointAnnotation
                key={`long${item.cord[0]}`}
                id={`${item.cord[0] + item.cord[1]}`}
                coordinate={[item.cord[0], item.cord[1]]}>
                <MyTxt item={item} />
                <Callout title="Place name" />
              </Mapbox.PointAnnotation>
            );
          })}
        </Mapbox.MapView>
        <Button title="Change markers" onPress={() => setmarkers(markers2)} />
      </View>
    </View>
  );
}
const styles = StyleSheet.create({
  page: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  container: {
    height: '100%',
    width: '100%',
  },
  map: {
    flex: 1,
  },
});

Simulator Screenshot - iPhone 15 Pro Max - 2024-03-11 at 10 43 07
Simulator Screenshot - iPhone 15 Pro Max - 2024-03-11 at 10 42 49

Observed behavior and steps to reproduce

Issue seems to be similar to https://github.com/rnmapbox/maps/issues/3412

Expected behavior

No response

Notes / preliminary analysis

No response

Additional links and references

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the standalone React Native reproduction and compare the behavior with related issue #3412. Investigate what happens when the markers state changes and the PointAnnotation components are replaced on iOS; done means changing markers no longer crashes and the updated annotations appear correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.