Skip to content
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

[Bug]: Crash on Android with dynamic shape source (Ios works fine), Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR) #3385

Open
stalteri opened this issue Feb 20, 2024 · 9 comments
Labels
bug 🪲 Something isn't working Needs: Author Feedback

Comments

@stalteri
Copy link

stalteri commented Feb 20, 2024

Mapbox Implementation

Mapbox

Mapbox Version

default

Platform

Android

@rnmapbox/maps version

10.1.13

Standalone component to reproduce

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Navigator, routes, MainStack } from 'app/navigation';
import { Feature, Geometry, Point, LineString, GeoJsonProperties, Position } from 'geojson';
import { LineLayer, ShapeSource, MapView, PointAnnotation } from '@rnmapbox/maps';

const styles = StyleSheet.create({
    waypoint: {
    width: 24,
    height: 24,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'white',
    borderRadius: 50,
  },
});

type Waypoint = {
  index: number;
  coordinates: Position;
  height: number;
};

const BugReportExample = () => {
  const [lineString, setLineString] = React.useState<LineString>({ type: 'LineString', coordinates: [] });
  const [points, setPoints] = React.useState<Waypoint[]>([]);
  const [cycled, setCycled] = React.useState<boolean>(false);

  const feature = React.useMemo<Feature<LineString>>(() => {
    return {
      type: 'Feature',
      properties: {
        id: 'clgnqq4xc00v4bpxv7hs9m5kt',
        name: 'FeatureLines',
      },
      geometry: lineString,
    };
  }, [lineString]);

  const updateLineString = React.useCallback((coordinates: Position) => {
    setLineString(prev => ({
      ...prev,
      coordinates: prev?.coordinates?.concat([coordinates]),
    } as LineString));
  }, []);

  const handlePress = React.useCallback((feature: Feature<Geometry, GeoJsonProperties>) => {
    if (feature.geometry.type === 'Point' && !cycled) {
      const point: Point = feature.geometry;

      setPoints(prev => [...prev, {
        index: prev.length,
        coordinates: point.coordinates,
        height: 0,
      }]);

      updateLineString(point.coordinates);
    }
  }, [cycled, updateLineString]);

  const handleDragEnd = React.useCallback((coordinates: Position, index: number) => {
    setPoints(prev => {
      const newPoints = prev;
      newPoints.splice(index, 1, { ...prev[index], coordinates });

      return newPoints;
    });

    setLineString(prev => {
      const newCoordinates = prev.coordinates;
      newCoordinates.splice(index, 1, coordinates);

      return {
        ...prev,
        coordinates: newCoordinates,
      };
    });
  }, []);

  const handleDrag = React.useCallback((coordinates: Position, index: number) => {
      setLineString(prev => {
      const newCoordinates = prev.coordinates;
      newCoordinates.splice(index, 1, coordinates);

      return {
        ...prev,
        coordinates: newCoordinates,
      };
    });
  }, []);

  const handleWaypointPress = React.useCallback((point: Waypoint, index: number) => {
    if (index === 0 && !cycled) {
      updateLineString(point.coordinates);
      setCycled(true);
    }
  }, [cycled, updateLineString]);

  return (
    <MapView
      style={{ flex: 1 }}
      onPress={handlePress}
      logoEnabled={false}
      scaleBarEnabled={false}
      styleURL='mapbox://styles/mapbox-map-design/ckhqrf2tz0dt119ny6azh975y'
    >
      {points.map((item, index) => (
        <PointAnnotation
          draggable
          id={String(index)}
          key={String(index)}
          coordinate={item.coordinates}
          onSelected={() => handleWaypointPress(item, index)}
          onDragEnd={feature => handleDragEnd(feature.geometry.coordinates, index)}
          onDrag={feature => handleDrag(feature.geometry.coordinates, index)}
        >
          <View style={styles.waypoint}>
            {typeof index === 'number' && <Text>{index + 1}</Text>}
          </View>
        </PointAnnotation>
      ))}

      <ShapeSource
        id='source'
        shape={feature}
        buffer={512}
        tolerance={0.5}
      >
        <LineLayer
          id='lines'
          layerIndex={11}
          sourceID='source'
          style={{
            lineWidth: 3,
            lineColor: 'white',
          }}
        />
      </ShapeSource>
    </MapView>
  );
};

export default BugReportExample;

Observed behavior and steps to reproduce

random crash on map with ShapeSource and also no lines were rendered
https://github.com/rnmapbox/maps/assets/48121568/3b3018fb-c91a-4679-894a-754892db668f

on ios works fine with no crashes and also lines renders
image

Expected behavior

no crash and render the LineSource just like on ios

Notes / preliminary analysis

Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x725f6adb60 in tid 20891 (Worker 2), pid 20767 (com.nexops)
2024-02-20 13:41:35.114 20972-20972 DEBUG pid-20972 A Cmdline: com.nexops
2024-02-20 13:41:35.114 20972-20972 DEBUG pid-20972 A pid: 20767, tid: 20891, name: Worker 2 >>> com.nexops <<<
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #1 pc 00000000000eab24 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libc++_shared.so (BuildId: a59088f9640cd272bc9542d94dc84a0c88afd558)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #2 pc 00000000000ea818 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libc++_shared.so (BuildId: a59088f9640cd272bc9542d94dc84a0c88afd558)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #3 pc 00000000000e6e30 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libc++_shared.so (BuildId: a59088f9640cd272bc9542d94dc84a0c88afd558)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #4 pc 00000000000e6cc0 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libc++_shared.so (__gxx_personality_v0+224) (BuildId: a59088f9640cd272bc9542d94dc84a0c88afd558)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #5 pc 0000000000143d4c /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-common.so (BuildId: b956b55bbfa93def)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #6 pc 0000000000144254 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-common.so (BuildId: b956b55bbfa93def)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #7 pc 000000000018f6dc /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-common.so (BuildId: b956b55bbfa93def)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #8 pc 0000000000192454 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-common.so (mapbox::common::geojson::convert(mapbox::feature::value const&)+420) (BuildId: b956b55bbfa93def)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #9 pc 00000000002c5368 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-maps.so (BuildId: 886096c02edc2c34)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #10 pc 000000000045c698 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-maps.so (BuildId: 886096c02edc2c34)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #11 pc 000000000045c448 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-maps.so (BuildId: 886096c02edc2c34)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #12 pc 00000000001aa3a8 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-common.so (mapbox::common::platform::processTask(std::__ndk1::function<void ()> const&)+32) (BuildId: b956b55bbfa93def)
2024-02-20 13:41:35.115 20972-20972 DEBUG pid-20972 A #13 pc 000000000019b7c0 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-common.so (BuildId: b956b55bbfa93def)

Additional links and references

maybe problem with this?

#8 pc 0000000000192454 /data/app/~~YUXzRXUVSEG_6Cvdl5Plqw==/com.nexops-0viZPywZ0VQYABftACdfCg==/lib/arm64/libmapbox-common.so (mapbox::common::geojson::convert(mapbox::feature::value const&)+420) (BuildId: b956b55bbfa93def)

@stalteri stalteri added the bug 🪲 Something isn't working label Feb 20, 2024
@stalteri stalteri changed the title [Bug]: Crash on Android with dynamic shape source (Ios works fine) [Bug]: Crash on Android with dynamic shape source (Ios works fine), Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR) Feb 20, 2024
@github-actions github-actions bot reopened this Feb 20, 2024
@mfazekas
Copy link
Contributor

Thanks for the report, I wasn't able to reproduce the issue in our env.
What is your RN version?

image

@stalteri
Copy link
Author

stalteri commented Feb 21, 2024

Thanks for response.

What is your RN version?

0.73.4
Android 13

@mfazekas
Copy link
Contributor

@stalteri I see our app uses 0.73.4 as well. Can you try to reproduce in our example app, or a new app created with npx react-native init?

@stalteri
Copy link
Author

@stalteri I see our app uses 0.73.4 as well. Can you try to reproduce in our example app, or a new app created with npx react-native init?

Ok, I'll try to reproduce asap.

@stalteri
Copy link
Author

stalteri commented Feb 21, 2024

@mfazekas

@stalteri I see our app uses 0.73.4 as well. Can you try to reproduce in our example app, or a new app created with npx react-native init?

Screen_Recording_20240221_105904_RNMapboxGLExample.mp4

P.S. I forget to add a "draggable" prop to PointAnnotation in the component to reproduce (alredy edited).

@VovkViktor
Copy link

VovkViktor commented Mar 11, 2024

I crashed too when I used ShapeSource with prop shape type 'LineString'. RN 0.73.5, "@rnmapbox/maps": "^10.1.18" and "@rnmapbox/maps": "^10.1.19"

 <MapboxGL.MapView
              ref={refMap}
              style={{flex: 1, width: '100%'}}
              styleURL={MapboxGL.StyleURL.Street}>
              <MapboxGL.ShapeSource
                id="lineSource"
                buffer={32}
                shape={{
                  type: 'LineString',
                  coordinates: locations,
                }}>
                <MapboxGL.LineLayer
                  id="lineLayer"
                  sourceID="lineSource"
                  style={{lineColor: 'blue', lineWidth: 3}}
                />
              </MapboxGL.ShapeSource>
              <MapboxGL.UserLocation
                visible={true}
                animated={true}
                androidRenderMode="gps"
              />
              <MapboxGL.Camera
                ref={cameraRef}
                allowUpdates={true}
                followUserLocation={true}
                animationMode="moveTo"
                animationDuration={200}
                followZoomLevel={16}
                defaultSettings={{
                  zoomLevel: 16,
                }}
              />
            </MapboxGL.MapView>

Also I created a new empty project on RN and installed only MapBox package. It isn't work too
image
image

@VovkViktor
Copy link

I noticed that it happens if "coordinates" prop array length less than 2

@stalteri
Copy link
Author

I noticed that it happens if "coordinates" prop array length less than 2

You are right, there no crash if I render ShapeSource only if coordinates length > 1

@wrldh
Copy link

wrldh commented May 9, 2024

Just had the same issue with version 10.1.21 and the reason is exact the same as described above (only one Position in ShapeSource's coordinates).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working Needs: Author Feedback
Projects
None yet
Development

No branches or pull requests

4 participants