maps: iOS: Unhandled error when offline

Describe the bug On iOS, an unhandled error is thrown if there is no network connection.

To Reproduce run on iOS and have device disconnected from the internet.

Example:

import React from 'react';
import MapboxGL from '@react-native-mapbox-gl/maps';

class BugReportExample extends React.Component {
  render() {
    return (
      <MapboxGL.MapView
          style={{ flex: 1 }}
          compassEnabled={true}
       styleURL={MapboxGL.StyleURL.Dark}
          localizeLabels={true}>

          <MapboxGL.Camera followZoomLevel={16} followUserLocation={true} followUserMode={'normal'} />

              <MapboxGL.SymbolLayer id="road-label-simple" style={{ visibility: 'none' }} />
              <MapboxGL.LineLayer id="road-simple" style={{ visibility: 'visible' }} />

          )}
          {children}
        </MapboxGL.MapView>
    );
  }
}

Expected behavior Expected to catch the error like on android

Screenshots Simulator Screen Shot - iPhone 11 - 2020-07-26 at 13 26 34

Versions (please complete the following information):

  • Platform: iOS
  • Device: iPhone 11
  • Emulator/ Simulator: yes
  • OS: iOS 13.4
  • react-native-mapbox-gl Version: 8.1.0-rc.2
  • React Native Version: 0.62.2

Additional context Hey, I would be happy to hear if someone has encountered a similar issue and how they have handled it. The maps work as expected both on iOS and android when online, and on android the error is not thrown.

Help would be much appreciated. Thanks

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@ibraude i think that’s just and error level log. You should be able to use Logger to filter this out.

Somehting like:

Logger.setLogCallback((log) => { 
  let {message} = log;
  if (message.match(/Requesting.+failed.+MGLNetworkConfiguration/)) {
    
    return true; // true means we've processed the log
  }
  return false;
})

@FernandesTeu Hey. I’ve used the Logger to filter out the specific errors I was encountering as @mfazekas suggested.

import Logger from '@react-native-mapbox-gl/maps/javascript/utils/Logger';

    Logger.setLogCallback((log) => {
      const { message } = log;
      console.log(message);
      if (message.match(/Requesting.+failed.+MGLNetworkConfiguration/) || message.match(/offline/)) {
        return true; // true means we've processed the log
      }
      return false;
    });
  }

This does the job for me until the issue is resolved.

Thank you all

@mfazekas, this issue seems to be fixed upstream. We “just” need to update the iOS SDK 😃

@ibraude i think that’s just and error level log. You should be able to use Logger to filter this out.

Somehting like:

Logger.setLogCallback((log) => { 
  let {message} = log;
  if (message.match(/Requesting.+failed.+MGLNetworkConfiguration/)) {
    
    return true; // true means we've processed the log
  }
  return false;
})