nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 699 forks source link

App crashes when remote images in ShapeSource are not found (404) #1621

Open noway opened 5 years ago

noway commented 5 years ago

When rendering ShapeSource with SymbolLayer like so:

const styles = MapboxGL.StyleSheet.create({
  something: {
    iconImage: '{id}',
    iconAllowOverlap: true,
    iconSize: 1,
    iconOpacity: 1,
  },
})

export default class Markers extends PureComponent {
  render() {
    const images = {
      '1': 'http://notfound.com/404'
    }
    return (
      <MapboxGL.Animated.ShapeSource id="somethings-source" images={images} shape={this.state.featureCollection}>
        <MapboxGL.Animated.SymbolLayer id="something" style={styles.something} />
      </MapboxGL.Animated.ShapeSource>
    )
  }
}

the whole app crashes with the following:

2019-05-20 13:34:19.773000+1200 app[533:362295] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot assign nil image to “1”.'
*** First throw call stack:
(0x20db7c518 0x20cd579f8 0x20da86c70 0x106568c90 0x1050a0658 0x10830b6f0 0x10830cc74 0x10831a6fc 0x20db0dec0 0x20db08df8 0x20db08354 0x20fd0879c 0x239f74b68 0x104ba0b8c 0x20d5ce8e0)
libc++abi.dylib: terminating with uncaught exception of type NSException

Version:

    "@mapbox/react-native-mapbox-gl": "^6.1.2",