maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.01k stars 296 forks source link

iOS: Map style does not reload when network comes online #2850

Open JesseCrocker opened 23 hours ago

JesseCrocker commented 23 hours ago

Describe the bug According to the docs

The map view automatically responds to changes in network connectivity by reloading the style.

but my testing indicates that this does not happen, either in my application or the sample app.

To Reproduce Steps to reproduce the behavior:

  1. Launch MapLibreApp on an iOS device
  2. Select SimpleMap
  3. turn off wifi and cellular
  4. Zoom the map in on a small pacific island
  5. Turn wifi back on

Expected behavior Tiles will load when device comes back online and full detail will show

Actual behavior Detail does not show

Screenshots WIfi off, zoom in IMG_0014

Wifi back on IMG_0015

Zoom out and in IMG_0016

Platform information (please complete the following information):

Additional context

I spent a few minutes debugging this in code, MLNMapView.reachabilityChanged does get called properly when connectivity changes, and mbgl::NetworkStatus::Reachable() is called properly when the network comes back online.

louwers commented 23 hours ago

Could you check if it's not just the Demotiles style?

JesseCrocker commented 23 hours ago

In the last screenshot it shows the full detail loaded after zooming out and in, so it's not that style not having detail. The same repro steps also show the same problem with the BuildingLight example, and I'm also seeing this same issue in my app.

voncannon commented 16 hours ago

I'm seeing the same issue. Weird, I never noticed that before. hmm

voncannon commented 16 hours ago

I tried a few things to get the style to reload as a workaround, but no luck. It's almost like those tiles that failed to load offline are stuck or something.

I tried to follow the code where mbgl::NetworkStatus::Reachable(); is set, but didn't see/find a place where it actually fetches the current tiles being displayed in the current visible bounds (if they aren't in cache).

I also see one test TEST(OnlineFileSource, TEST_REQUIRES_SERVER(NetworkStatusChangePreempt)) in /test/storage/online_file_source.test.cpp that might be related.

voncannon commented 16 hours ago

Oh yea, and I did verify kMLNReachabilityChangedNotification is getting fired:

extension Notification.Name {
    static let kMLNReachabilityChangedNotification = Notification.Name("kMLNReachabilityChangedNotification")
}

NotificationCenter.default.addObserver(self, selector: #selector(kittens), name: Notification.Name.kMLNReachabilityChangedNotification, object: nil)

@objc func kittens() {
    print("Yep")
}

Could probably do something hacky to reload the map there... 🙀 but best to fix it right