Repository navigation
[ios] Add a flag to pause network requests. - #15650
fabian-guerra wants to merge 9 commits into
Conversation
|
FYI @tobrun |
1ce830a to
78fd9d6
Compare
|
I see I'm wondering if in addition to @tmpsantos would you mind adding your 2 cents here? |
| auto shared = request->shared; // Explicit copy so that it also gets copied into the completion handler block below. | ||
|
|
||
| if ([MGLNetworkConfiguration sharedManager].stopsRequests) { | ||
| return std::move(request); |
There was a problem hiding this comment.
The problem with this implementation is when you resume, it will not re-request the previously requested (but not fulfilled) network requests.
We have an API for this: mbgl::NetworkStatus::Set(NetworkStatus::Status::Offline).
|
The The api that @tmpsantos mentiones we expose on the Map object ( |
friedbunny
left a comment
There was a problem hiding this comment.
We have to add tests for this before it can be accepted.
|
|
||
| - (BOOL)stopsRequests { | ||
| auto status = mbgl::NetworkStatus::Get(); | ||
| if (status == mbgl::NetworkStatus::Status::Offline) { |
There was a problem hiding this comment.
This can just be return (status == mbgl::NetworkStatus::Status::Offline);
|
|
||
| - (void)setStopsRequests:(BOOL)stopsRequests { | ||
| if (stopsRequests) { | ||
| mbgl::NetworkStatus::Set(mbgl::NetworkStatus::Status::Offline); |
There was a problem hiding this comment.
I could be wrong, but this will be Offline forever. Because once you set the status to Offline, the following code will always be true.
- (BOOL)stopsRequests {
auto status = mbgl::NetworkStatus::Get();
return status == mbgl::NetworkStatus::Status::Offline;
}
| return sessionConfiguration; | ||
| } | ||
|
|
||
| - (void)setStopsRequests:(BOOL)stopsRequests { |
There was a problem hiding this comment.
stopRequests is not really a great name for this API, because is a double negation.
There was a problem hiding this comment.
I agree with this; @tobrun will setConnected remain the same?
@fabian-guerra how about we go with a connected property? My concern here is that this might be confused whether there is a valid connection (a la reachability).
There was a problem hiding this comment.
I think we should match Android in this instance; let's discuss.
| networkStatus = mbgl::NetworkStatus::Get(); | ||
| offline = networkStatus == mbgl::NetworkStatus::Status::Offline ? YES : NO; | ||
| XCTAssertEqual([MGLNetworkConfiguration sharedManager].stopsRequests, offline); | ||
| } |
There was a problem hiding this comment.
These tests look good, thanks! Have you considered implementing tests of the offline/network functionality — e.g., does enabling this property actually result in no network requests?
There was a problem hiding this comment.
My understanding is that this will stop tile and related requests, but other network activity would still occur.
a4bc0c4 to
53b0b2f
Compare
julianrex
left a comment
There was a problem hiding this comment.
Just a couple of notes.
| return sessionConfiguration; | ||
| } | ||
|
|
||
| - (void)setStopsRequests:(BOOL)stopsRequests { |
There was a problem hiding this comment.
I think we should match Android in this instance; let's discuss.
|
|
||
| networkStatus = mbgl::NetworkStatus::Get(); | ||
| offline = networkStatus == mbgl::NetworkStatus::Status::Offline ? YES : NO; | ||
| // TODO: When the double linking framework fix lands this should be replaced to an equal assert |
There was a problem hiding this comment.
Let's link to an issue here that gives more detail. Perhaps #15724 ?
|
It crashes the app when I am trying to use it: |
|
@fabian-guerra @knov Closing this PR in preference of mapbox/mapbox-gl-native-ios#217, which tracks whether this needs to be ported. |
|
Continues in mapbox/mapbox-gl-native-ios#416 |
Fixes #7443.
Adds the iOS equivalent of Android's
setConnectedflag. Unlike Android iOS don't have aConnectivityManagerto turn on/off the network requests. The network implementation checks if thestopsRequestsflag is set toYESthe core network library will stop making request. This enforce the usage of any previously cached data.