Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Locally served resources not requested when network disconnects #9608

Closed
jthetzel opened this issue Jul 25, 2017 · 1 comment
Closed

Locally served resources not requested when network disconnects #9608

jthetzel opened this issue Jul 25, 2017 · 1 comment
Labels
Android Mapbox Maps SDK for Android support

Comments

@jthetzel
Copy link

Platform: Android (using react-native-mapbox-gl)
Mapbox SDK version: 4.2.2

Steps to trigger behavior

  1. Render a tile source hosted locally on the Android device (using nanohttpd). For example, style.json is:
    { "version": 8, "sources": { "offline": { "type": "raster", "tiles": [ "http://127.0.0.1:8080/tiles/{z}/{x}/{y}.png" ], "maxzoom": 12 } }, "layers": [ { "id": "offline", "type": "raster", "source": "offline" } ] }
  2. Check that locally hosted tiles render correctly in Mapbox.
  3. Turn off cellular data and wifi.

Expected behavior

Mapbox continues to fetch and render the locally hosted tiles.

Actual behavior

Mapbox no longer fetches tiles from the locally hosted source. Logcat warns 07-25 09:24:49.846: W/MapboxEventManager(4486): Not connected to network, so empty events cache and return without attempting to send events.

I presume this is related to #6123, where Mapbox is detecting a lack of network connection and not requesting resources to avoid 404 errors. However, http://127.0.0.1:8080/tiles/{z}/{x}/{y}.png is still available (I can manually fetch them within the app and receive a 200 response) . It would be nice if the offline check could be disabled in AndroidManifest.xml.

@tobrun tobrun added Android Mapbox Maps SDK for Android support labels Jul 25, 2017
@tobrun
Copy link
Member

tobrun commented Jul 25, 2017

@jthetzel

We actually support overriding the connection status through Mapbox#setConnected(true)

  /**
   * Manually sets the connectivity state of the app. This is useful for apps which control their
   * own connectivity state and want to bypass any checks to the ConnectivityManager.
   *
   * @param connected flag to determine the connectivity state, true for connected, false for
   *                  disconnected, and null for ConnectivityManager to determine.
   */
  public static synchronized void setConnected(Boolean connected) {
    // Connectivity state overridden by app
    INSTANCE.connected = connected;
  }

Closing this issue as answered. Let us know if you run into any issues.

@tobrun tobrun closed this as completed Jul 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android support
Projects
None yet
Development

No branches or pull requests

2 participants