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

Versions (please complete the following information):
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
@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;
})
I've also been encountering this issue when the network is not available on iOS. It happens in both debug and release mode.
I tried the solution above, but in my case there isn't any error callback to the Logger made before the app crashes it seems. I also never get the red error screen, instead the app crashes right away...
Sentry log
OS Version: iOS 12.4.6 (16G183)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: SEGV_NOOP at 0x0000000000000001
Crashed Thread: 22
Application Specific Information:
_dynamicContextEvaluation:patternString: > Requesting: %@ failed with error: %@ > respondsToSelector: > te:inRange:options:usingBlock: >
Attempted to dereference garbage pointer 0x1.
Thread 22 Crashed:
0 libobjc.A.dylib 0x36ec95528 objc_msgSend
1 Foundation 0x370cf4064 _NSDescriptionWithStringProxyFunc
2 CoreFoundation 0x3703b0404 __CFStringAppendFormatCore
3 CoreFoundation 0x3703b25b8 _CFStringCreateWithFormatAndArgumentsAux2
4 Mapbox 0x1041d1290 -[MGLLoggingConfiguration logCallingFunction:functionLine:messageType:format:] (MGLLoggingConfiguration.mm:72)
5 Mapbox 0x104192ac8 -[MGLNetworkIntegrationManager errorLog:] (MGLNetworkIntegrationManager.m:51)
6 Mapbox 0x103ea4068 -[MGLNativeNetworkManager errorLog:] (native_apple_interface.m:69)
7 Mapbox 0x103ea0ee0 mbgl::HTTPFileSource::request (http_file_source.mm:265)
8 MyApp 0x200b71700 __79+[FLEXNetworkObserver asyncCompletionWrapperForRequestID:mechanism:completion:]_block_invoke
9 CFNetwork 0x37074e684 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke
10 CFNetwork 0x37076221c __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke
11 Foundation 0x370cd4cf0 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
12 Foundation 0x370be0d8c -[NSBlockOperation main]
13 Foundation 0x370be0274 -[__NSOperationInternal _start:]
14 Foundation 0x370cd6a74 __NSOQSchedule_f
15 libdispatch.dylib 0x36f514a34 _dispatch_call_block_and_release
16 libdispatch.dylib 0x36f5157d0 _dispatch_client_callout
17 libdispatch.dylib 0x36f4ba018 _dispatch_continuation_pop$VARIANT$mp
18 libdispatch.dylib 0x36f4b9798 _dispatch_async_redirect_invoke
19 libdispatch.dylib 0x36f4c602c _dispatch_root_queue_drain
20 libdispatch.dylib 0x36f4c68d0 _dispatch_worker_thread2
21 libsystem_pthread.dylib 0x36f5301b0 _pthread_wqthread
Could there be another solution to prevent the crashes ?
Help would be appreciated.
Not sure if this is related, however just found it after a quick google search, maybe it helps:
https://github.com/mapbox/mapbox-gl-native/issues/16511
Thanks for the answer @ferdicus. I'm already tracking that issue. I think you're right, the issues seem related.
But is there maybe an easy way to stop the mapbox from attempting to write those logs altogether ?
sorry @ghitier, I'm not sure 🤷
I'm not really that well versed when it comes to the native bits :(
Yeah me neither. Let's hope that they they'll find something in the issue you linked.
@mfazekas, this issue seems to be fixed upstream.
We "just" need to update the iOS SDK :)
@ferdicus Are there a lot of Breaking Changes in the new iOS SDK upgrade?
I haven't really looked at the changes besides this issue and updates to the license and distribution of mapbox iOS
Those will at the very least need some updates to the installation guides
Okay cool, found the following in the description:
"This major release does not include any breaking changes to public APIs. We are treating this release as a SEMVER major change because our installation instructions have changed.”
Interesting.
--
Sent from Canary (https://canarymail.io)
On Friday, Aug 28, 2020 at 9:05 AM, Kid Commit
I haven't really looked at the changes besides this issue and updates to the license and distribution of mapbox iOS (https://github.com/mapbox/mapbox-gl-native-ios/releases/tag/ios-v6.0.0)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub (https://github.com/react-native-mapbox-gl/maps/issues/971#issuecomment-682676118), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AAG2QB4RWTQFZ47NWSOS57DSC7BSLANCNFSM4PH5MRAA).
@ibraude Did you find the answer about this error??
@ibraude i think that's just and error level log.
You should be able to useLoggerto 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
@ibraude I called this CallBack into ComponentDidMount, but not worked for me? Sorry, I'm noob in React Native....
@FernandesTeu Try putting it in the class constructor like so:
constructor(props) {
super(props);
MapboxGL.setTelemetryEnabled(false);
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;
});
}
@ibraude thank you so much....I followed your tip and I still get the error... Did you have the problem with IOS 14 ?
@FernandesTeu I did not check iOS 14 specifically.
Maybe you're getting a different error message?
Try adjusting the Regex to match the error message you're seeing.
@ibraude You were right...my message error was MGLNativeNetworkManager, now it's working!
Thanks for your help Ibraude, I really appreciate it
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.