Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Libraries/Geolocation/RCTLocationObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ @implementation RCTLocationRequest

- (void)dealloc
{
[_timeoutTimer invalidate];
if (_timeoutTimer.valid) {
[_timeoutTimer invalidate];
}
}

@end
Expand Down Expand Up @@ -273,6 +275,7 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray
// Fire all queued callbacks
for (RCTLocationRequest *request in _pendingRequests) {
request.successBlock(@[_lastLocationEvent]);
[request.timeoutTimer invalidate];
}
[_pendingRequests removeAllObjects];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new invalidate calls shouldn't be necessary because this should be invalidating the timers because all the requests should be dealloc'd at this point. If that's not happening, there is probably a retain cycle or something? cc @nicklockwood


Expand Down Expand Up @@ -311,6 +314,7 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *
// Fire all queued error callbacks
for (RCTLocationRequest *request in _pendingRequests) {
request.errorBlock(@[jsError]);
[request.timeoutTimer invalidate];
}
[_pendingRequests removeAllObjects];

Expand Down